Changeset 7901
- Timestamp:
- Jul 13, 2006, 4:26:25 PM (20 years ago)
- Location:
- trunk/psLib
- Files:
-
- 1 added
- 13 edited
-
src/math/psRegion.c (modified) (3 diffs)
-
src/math/psRegion.h (modified) (2 diffs)
-
src/sys/psLine.c (modified) (2 diffs)
-
src/sys/psLine.h (modified) (3 diffs)
-
src/sys/psMemory.c (modified) (6 diffs)
-
src/sys/psMemory.h (modified) (2 diffs)
-
src/sys/psString.c (modified) (3 diffs)
-
src/sys/psString.h (modified) (3 diffs)
-
src/sys/psType.h (modified) (2 diffs)
-
test/sys/Makefile.am (modified) (2 diffs)
-
test/sys/tst_psLine.c (added)
-
test/sys/tst_psString.c (modified) (4 diffs)
-
test/sys/verified/tst_psString.stderr (modified) (1 diff)
-
test/types/verified/tst_psMetadata_06.stdout (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psRegion.c
r7563 r7901 6 6 #include "psRegion.h" 7 7 8 static void regionFree(psRegion *region) 9 { 10 // There are non dynamic allocated items 11 } 12 8 13 psRegion *psRegionAlloc(float x0, 9 14 float x1, … … 12 17 { 13 18 psRegion *region = psAlloc(sizeof(psRegion)); // New region, to be returned 19 psMemSetDeallocator(region, (psFreeFunc)regionFree); 14 20 // No complex structures, so no special deallocator 15 21 *region = psRegionSet(x0, x1, y0, y1); … … 101 107 } 102 108 109 bool psMemCheckRegion(psPtr ptr) 110 { 111 if (!is_psType(ptr)) { 112 return false; 113 } 114 return ( psMemGetDeallocator(ptr) == (psFreeFunc)regionFree ); 115 } 116 117 -
trunk/psLib/src/math/psRegion.h
r7563 r7901 27 27 float y1 ///< the last row of the region + 1. 28 28 ); 29 30 /** Checks the type of a particular pointer. 31 * 32 * Uses the appropriate deallocation function in psMemBlock to check the ptr datatype. 33 * 34 * @return bool: True if the pointer matches a psRegion structure, false otherwise. 35 */ 36 bool psMemCheckRegion( 37 psPtr ptr ///< the pointer whose type to check 38 ); 29 39 30 40 /** Create a psRegion with the specified attributes. … … 70 80 ); 71 81 72 // Test if any element of the region is NaN 73 bool psRegionIsNaN(psRegion region// Region to check 74 ); 82 /** Test if any element of the region is NaN 83 * 84 * @return bool: True if an element is NaN, otherwise false. 85 */ 86 bool psRegionIsNaN( 87 psRegion region ///< Region to check 88 ); 75 89 76 90 #endif -
trunk/psLib/src/sys/psLine.c
r7380 r7901 39 39 } 40 40 41 bool psLineAdd(psLine *line, const char *format, ...) 41 bool psLineAdd(psLine *line, 42 const char *format, 43 ...) 42 44 { 43 45 if (!line) { … … 58 60 return true; 59 61 } 62 63 bool psMemCheckLine(psPtr ptr) 64 { 65 if (!is_psType(ptr)) { 66 return false; 67 } 68 return ( psMemGetDeallocator(ptr) == (psFreeFunc)lineFree ); 69 } 70 -
trunk/psLib/src/sys/psLine.h
r7847 r7901 1 1 /** @file psLine.h 2 2 * 3 * the psLine functions allow manipulation of fixed-length lines 3 * 4 * @brief Contains the declarations of line utility functions 5 * 6 * @ingroup SysUtils 7 * 8 * The psLine functions allow manipulation of fixed-length lines. 9 * 10 * @author Paul Price, IFA 11 * @author David Robbins, MHPCC 12 * 13 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2006-07-14 02:26:25 $ 15 * 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 4 17 */ 5 18 6 19 #ifndef PS_LINE_H 7 20 #define PS_LINE_H 21 22 /** @addtogroup SysUtils 23 * @{ 24 */ 8 25 9 26 /** Structure to carry a dynamic string */ … … 16 33 psLine; 17 34 18 /** Allocates a line object of length Nline 35 /** Allocates a line object of length Nline. 19 36 * 20 37 * @return psLine*: the newly allocated line object. 21 38 */ 22 39 psLine *psLineAlloc( 23 long Nline ///< 40 long Nline ///< length of line object to allocate 41 ); 42 43 /** Checks the type of a particular pointer. 44 * 45 * Uses the appropriate deallocation function in psMemBlock to check the ptr datatype. 46 * 47 * @return bool: True if the pointer matches a psLine structure, false otherwise. 48 */ 49 bool psMemCheckLine( 50 psPtr ptr ///< the pointer whose type to check 24 51 ); 25 52 … … 32 59 */ 33 60 bool psLineInit( 34 psLine *line ///< 61 psLine *line ///< line to (re-)initialize 35 62 ); 36 63 -
trunk/psLib/src/sys/psMemory.c
r7617 r7901 8 8 * @author Robert Lupton, Princeton University 9 9 * 10 * @version $Revision: 1.7 3$ $Name: not supported by cvs2svn $11 * @date $Date: 2006-0 6-21 21:40:12$10 * @version $Revision: 1.74 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2006-07-14 02:26:25 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 24 24 #include "psAbort.h" 25 25 #include "psLogMsg.h" 26 27 26 #include "psBitSet.h" 28 //#include "psArray.h"29 //#include "psImage.h"30 //#include "psList.h"31 //#include "psLookupTable.h"32 //#include "psHash.h"33 34 //#include "psMetadata.h"35 27 #include "psFits.h" 36 28 #include "psPixels.h" 37 //#include "psScalar.h"38 //#include "psVector.h"39 //#include "psTime.h"40 //#include "psCoord.h"41 29 #include "psSphereOps.h" 42 //#include "psStats.h"43 30 #include "psMinimizeLMM.h" 44 31 #include "psImageConvolve.h" 45 32 #include "psTime.h" 46 33 #include "psLine.h" 34 #include "psRegion.h" 47 35 #include "psErrorText.h" 48 36 … … 837 825 } 838 826 827 bool is_psType(psPtr ptr) 828 { 829 if (ptr == NULL) { 830 return false; 831 } 832 psMemBlock* m = ((psMemBlock* ) ptr) - 1; 833 if (m->startblock != P_PS_MEMMAGIC || m->endblock != P_PS_MEMMAGIC) { 834 return false; //Probably not a psAllocated-Type 835 } else { 836 return true; 837 } 838 } 839 839 840 bool psMemCheckType(psDataType type, 840 841 psPtr ptr) 841 842 { 843 if (!is_psType(ptr)) { 844 return false; 845 } 846 842 847 switch(type) { 843 848 case PS_DATA_ARRAY: … … 905 910 break; 906 911 } 912 case PS_DATA_LINE: 913 if ( psMemCheckLine(ptr) ) 914 return true; 915 else { 916 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 917 "Incorrect pointer. Datatypes do not match.\n"); 918 break; 919 } 907 920 case PS_DATA_LIST: 908 921 if ( psMemCheckList(ptr) ) … … 1017 1030 break; 1018 1031 } 1032 case PS_DATA_REGION: 1033 if ( psMemCheckRegion(ptr) ) 1034 return true; 1035 else { 1036 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 1037 "Incorrect pointer. Datatypes do not match.\n"); 1038 break; 1039 } 1019 1040 case PS_DATA_SCALAR: 1020 1041 if ( psMemCheckScalar(ptr) ) … … 1051 1072 case PS_DATA_STATS: 1052 1073 if ( psMemCheckStats(ptr) ) 1074 return true; 1075 else { 1076 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 1077 "Incorrect pointer. Datatypes do not match.\n"); 1078 break; 1079 } 1080 case PS_DATA_STRING: 1081 if ( psMemCheckString(ptr) ) 1053 1082 return true; 1054 1083 else { -
trunk/psLib/src/sys/psMemory.h
r7617 r7901 12 12 * @ingroup MemoryManagement 13 13 * 14 * @version $Revision: 1.5 6$ $Name: not supported by cvs2svn $15 * @date $Date: 2006-0 6-21 21:40:12$14 * @version $Revision: 1.57 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2006-07-14 02:26:25 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 172 172 ); 173 173 174 bool is_psType( 175 psPtr ptr 176 ); 177 174 178 /** Checks the deallocator to see if the pointer matches the desired datatype. 175 179 * -
trunk/psLib/src/sys/psString.c
r7879 r7901 13 13 * @author David Robbins, MHPCC 14 14 * 15 * @version $Revision: 1.3 6$ $Name: not supported by cvs2svn $16 * @date $Date: 2006-07-1 2 21:17:51$15 * @version $Revision: 1.37 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2006-07-14 02:26:25 $ 17 17 * 18 18 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 30 30 #include "psErrorText.h" 31 31 32 static void stringFree(psString string) 33 { 34 // There is non dynamic allocated item 35 } 36 37 psString psStringAlloc(long nChar) 38 { 39 if (nChar < 1) { 40 return NULL; 41 } 42 psString string = psAlloc(nChar + 1); 43 psMemSetDeallocator(string, (psFreeFunc)stringFree); 44 return string; 45 } 46 47 bool psMemCheckString(psPtr ptr) 48 { 49 if (!is_psType(ptr)) { 50 return false; 51 } 52 return ( psMemGetDeallocator(ptr) == (psFreeFunc)stringFree ); 53 } 54 32 55 psString psStringCopy(const char *string) 33 56 { … … 231 254 return input; 232 255 } 256 if (!psMemCheckString(input)) { 257 return input; 258 } 259 233 260 234 261 // replace == NULL is valid: it just means that we strip out the key -
trunk/psLib/src/sys/psString.h
r7853 r7901 14 14 * @author David Robbins, MHPCC 15 15 * 16 * @version $Revision: 1.2 5$ $Name: not supported by cvs2svn $17 * @date $Date: 2006-07-1 0 20:15:43$16 * @version $Revision: 1.26 $ $Name: not supported by cvs2svn $ 17 * @date $Date: 2006-07-14 02:26:25 $ 18 18 * 19 19 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 39 39 * @{ 40 40 */ 41 42 /** Allocates a new psString. 43 * 44 * @return psString: Newly allocated string of length n. 45 */ 46 psString psStringAlloc( 47 long nChar ///< Size of psString to allocate. 48 ); 49 50 /** Checks the type of a particular pointer. 51 * 52 * Uses the appropriate deallocation function in psMemBlock to check the ptr datatype. 53 * 54 * @return bool: True if the pointer matches a psString structure, false otherwise. 55 */ 56 bool psMemCheckString( 57 psPtr ptr ///< the pointer whose type to check 58 ); 41 59 42 60 /** Copies the input string … … 145 163 ); 146 164 147 148 165 /** @} */// Doxygen - End of SystemGroup Functions 149 166 -
trunk/psLib/src/sys/psType.h
r7472 r7901 10 10 * @author Ross Harman, MHPCC 11 11 * 12 * @version $Revision: 1.5 0$ $Name: not supported by cvs2svn $13 * @date $Date: 2006-0 6-10 02:28:17$12 * @version $Revision: 1.51 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2006-07-14 02:26:25 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 118 118 PS_DATA_IMAGE, ///< psImage 119 119 PS_DATA_KERNEL, ///< psKernel 120 PS_DATA_LINE, ///< psLine 120 121 PS_DATA_LIST, ///< psList 121 122 PS_DATA_LOOKUPTABLE, ///< psLookupTable -
trunk/psLib/test/sys/Makefile.am
r7884 r7901 12 12 tst_psString \ 13 13 tst_psTrace \ 14 tap_psStringSubstitute 14 tap_psStringSubstitute \ 15 tst_psLine 15 16 16 17 tst_psAbort_SOURCES = tst_psAbort.c … … 21 22 tst_psString_SOURCES = tst_psString.c 22 23 tst_psTrace_SOURCES = tst_psTrace.c 24 tst_psLine_SOURCES = tst_psLine.c 23 25 24 26 tap_psStringSubstitute_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/test/tap/src -
trunk/psLib/test/sys/tst_psString.c
r7880 r7901 20 20 * @author Eric Van Alst, MHPCC 21 21 * 22 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $23 * @date $Date: 2006-07-1 2 21:25:39$22 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 23 * @date $Date: 2006-07-14 02:26:25 $ 24 24 * 25 25 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 53 53 static psS32 testStrSplit00(void); 54 54 static psS32 testNULLStrings(void); 55 static psS32 testStrCheck(void); 55 56 56 57 testDescription tests[] = { … … 74 75 {testStrSplit00,15, "Test String Splitting", 0, false}, 75 76 {testNULLStrings,666, "Test NULL String Error Handling", 0, false}, 77 {testStrCheck,16, "Test String Allocation and MemCheck", 0, false}, 76 78 {NULL} 77 79 }; … … 709 711 return 0; 710 712 } 713 714 psS32 testStrCheck(void) 715 { 716 psString str = NULL; 717 str = psStringAlloc(10); 718 strcpy(str, "Hello"); 719 if (!psMemCheckString(str)) { 720 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 721 "psString wasn't properly allocated!\n"); 722 return 1; 723 } 724 if (!psMemCheckType(PS_DATA_STRING, str)) { 725 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 726 "psString wasn't properly allocated!\n"); 727 return 2; 728 } 729 psFree(str); 730 731 char charStr[10]; 732 if (psMemCheckType(PS_DATA_STRING, charStr)) { 733 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 734 "Input string is not a psDataType!!! (Should have returned false)\n"); 735 return 3; 736 } 737 738 return 0; 739 } 740 -
trunk/psLib/test/sys/verified/tst_psString.stderr
r7880 r7901 175 175 ---> TESTPOINT PASSED (psString{Test NULL String Error Handling} | tst_psString.c) 176 176 177 /***************************** TESTPOINT ******************************************\ 178 * TestFile: tst_psString.c * 179 * TestPoint: psString{Test String Allocation and MemCheck} * 180 * TestType: Positive * 181 \**********************************************************************************/ 182 183 184 ---> TESTPOINT PASSED (psString{Test String Allocation and MemCheck} | tst_psString.c) 185 -
trunk/psLib/test/types/verified/tst_psMetadata_06.stdout
r5454 r7901 9 9 Key Name: myItem1 Key mdType: 0x00000104 Key Value: 222 Key Comment: I am a signed integer 10 10 Key Name: myItem2 Key mdType: 0x00000104 Key Value: 333 Key Comment: I am a signed integer 11 Key Name: myItem2 Key mdType: 0x0001000 9Key Value: psList Key Comment: I am a list11 Key Name: myItem2 Key mdType: 0x0001000a Key Value: psList Key Comment: I am a list 12 12 13 13 ---> TESTPOINT PASSED (psMetadata{Test A - Allocate metadata and items} | tst_psMetadata_06.c)
Note:
See TracChangeset
for help on using the changeset viewer.
