Changeset 9538 for trunk/psLib/src/sys
- Timestamp:
- Oct 13, 2006, 11:13:48 AM (20 years ago)
- Location:
- trunk/psLib/src/sys
- Files:
-
- 9 edited
-
psAssert.h (modified) (1 diff)
-
psConfigure.c (modified) (2 diffs)
-
psConfigure.h (modified) (2 diffs)
-
psLine.c (modified) (2 diffs)
-
psMemory.c (modified) (5 diffs)
-
psMemory.h (modified) (3 diffs)
-
psSlurp.c (modified) (2 diffs)
-
psSlurp.h (modified) (1 diff)
-
psString.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sys/psAssert.h
r8921 r9538 6 6 #include <math.h> 7 7 8 #include "psMemory.h" 8 9 #include "psError.h" 9 10 #include "psLogMsg.h" 11 12 // Ensure this is a psLib pointer, by checking for the memblock bounds. 13 #define PS_ASSERT_PTR(NAME, RVAL) \ 14 { \ 15 psMemBlock *mb = (psMemBlock*)(NAME) - 1; \ 16 if (mb->startblock != P_PS_MEMMAGIC || mb->endblock != P_PS_MEMMAGIC || \ 17 *(psPtr *)((int8_t *) (mb + 1) + mb->userMemorySize) != P_PS_MEMMAGIC) { \ 18 psError(PS_ERR_MEMORY_CORRUPTION, false, \ 19 "Error: Pointer %s is corrupted or not on the PS memory system.", \ 20 #NAME); \ 21 return (RVAL); \ 22 } \ 23 } 10 24 11 25 #define PS_ASSERT_INT_UNEQUAL(NAME1, NAME2, RVAL) \ -
trunk/psLib/src/sys/psConfigure.c
r8627 r9538 13 13 * @author Robert DeSonia, MHPCC 14 14 * 15 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $16 * @date $Date: 2006- 08-26 04:34:28 $15 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2006-10-13 21:13:48 $ 17 17 * 18 18 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 34 34 static FILE *memCheckFile = NULL; // File to which to write results of mem check 35 35 36 char*psLibVersion(void)36 psString psLibVersion(void) 37 37 { 38 38 char version[80]; -
trunk/psLib/src/sys/psConfigure.h
r7646 r9538 13 13 * @author Robert DeSonia, MHPCC 14 14 * 15 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $16 * @date $Date: 2006- 06-23 01:59:15$15 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2006-10-13 21:13:48 $ 17 17 * 18 18 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 32 32 * @return char*: String with version name. 33 33 */ 34 char*psLibVersion(34 psString psLibVersion( 35 35 void 36 36 ); -
trunk/psLib/src/sys/psLine.c
r7950 r9538 3 3 4 4 #include "psMemory.h" 5 #include "psAssert.h" 5 6 #include "psConstants.h" 6 7 #include "psLine.h" … … 64 65 bool psMemCheckLine(psPtr ptr) 65 66 { 66 if (!is_psType(ptr)) { 67 return false; 68 } 67 PS_ASSERT_PTR(ptr, false); 69 68 return ( psMemGetDeallocator(ptr) == (psFreeFunc)lineFree ); 70 69 } -
trunk/psLib/src/sys/psMemory.c
r8812 r9538 8 8 * @author Robert Lupton, Princeton University 9 9 * 10 * @version $Revision: 1.8 5$ $Name: not supported by cvs2svn $11 * @date $Date: 2006- 09-14 22:27:29$10 * @version $Revision: 1.86 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2006-10-13 21:13:48 $ 12 12 * 13 13 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 24 24 #include "psMemory.h" 25 25 #include "psError.h" 26 #include "psAssert.h" 26 27 #include "psAbort.h" 27 28 #include "psLogMsg.h" … … 35 36 #include "psLine.h" 36 37 #include "psRegion.h" 37 38 #define P_PS_MEMMAGIC (psPtr )0xdeadbeef // Magic number in psMemBlock header39 38 40 39 #define P_PS_LARGE_BLOCK_SIZE 65536 // size where under, we try to recycle … … 274 273 psMemId psMemGetId(void) 275 274 { 276 psMemId id; 277 278 if (safeThreads) { 279 pthread_mutex_lock(&memIdMutex); 280 } 281 282 id = memid + 1; 283 284 if (safeThreads) { 285 pthread_mutex_unlock(&memIdMutex); 286 } 287 288 return id; 275 return psMemGetLastId() + 1; 289 276 } 290 277 … … 889 876 } 890 877 891 bool is_psType(psPtr ptr)892 {893 if (ptr == NULL) {894 return false;895 }896 psMemBlock* m = ((psMemBlock* ) ptr) - 1;897 if (m->startblock != P_PS_MEMMAGIC || m->endblock != P_PS_MEMMAGIC) {898 return false; //Probably not a psAllocated-Type899 } else {900 return true;901 }902 }903 904 878 bool psMemCheckType(psDataType type, 905 879 psPtr ptr) 906 880 { 907 if (!is_psType(ptr)) { 908 return false; 909 } 881 PS_ASSERT_PTR(ptr, false); 910 882 911 883 switch(type) { -
trunk/psLib/src/sys/psMemory.h
r8705 r9538 12 12 * @ingroup MemoryManagement 13 13 * 14 * @version $Revision: 1.6 0$ $Name: not supported by cvs2svn $15 * @date $Date: 2006- 08-30 04:40:56$14 * @version $Revision: 1.61 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2006-10-13 21:13:48 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 29 29 * @{ 30 30 */ 31 32 #define P_PS_MEMMAGIC (psPtr)0xdeadbeef // Magic number in psMemBlock header 31 33 32 34 /** … … 172 174 ); 173 175 174 /** Tells whether or not a pointer has been allocated as a psDataType.175 *176 * @return bool: True if ptr is a psDataType, otherwise false.177 */178 bool is_psType(179 psPtr ptr ///< The pointer whose type to check180 );181 182 176 /** Checks the deallocator to see if the pointer matches the desired datatype. 183 177 * -
trunk/psLib/src/sys/psSlurp.c
r9002 r9538 5 5 * @author Joshua Hoblitt, University of Hawaii 6 6 * 7 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $8 * @date $Date: 2006- 09-27 03:50:19$7 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2006-10-13 21:13:48 $ 9 9 * 10 10 * Copyright 2006 University of Hawaii … … 15 15 #endif 16 16 17 #include <stdio.h> 17 18 #include <unistd.h> 18 19 -
trunk/psLib/src/sys/psSlurp.h
r8996 r9538 1 #ifndef PS_SLURP_H 2 #define PS_SLURP_H 3 1 4 #include <stdio.h> 2 #include <pslib.h>5 #include "psString.h" 3 6 4 psString psSlurpFD(int fd); 5 psString psSlurpFile(FILE *stream); 7 8 // Read ("slurp") a file (specified by file descriptor) 9 // and return a string containing the entire file. 10 psString psSlurpFD(int fd // File descriptor to read 11 ); 12 13 // Read ("slurp") a file (specified by file stream) 14 // and return a string containing the entire file. 15 psString psSlurpFile(FILE *stream // File stream to read 16 ); 17 18 19 #endif -
trunk/psLib/src/sys/psString.c
r9509 r9538 13 13 * @author David Robbins, MHPCC 14 14 * 15 * @version $Revision: 1.4 4$ $Name: not supported by cvs2svn $16 * @date $Date: 2006-10-1 2 21:31:47$15 * @version $Revision: 1.45 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2006-10-13 21:13:48 $ 17 17 * 18 18 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 47 47 bool psMemCheckString(psPtr ptr) 48 48 { 49 if (!is_psType(ptr)) { 50 return false; 51 } 49 PS_ASSERT_PTR(ptr, false); 52 50 return ( psMemGetDeallocator(ptr) == (psFreeFunc)stringFree ); 53 51 }
Note:
See TracChangeset
for help on using the changeset viewer.
