Changeset 1730 for trunk/psLib/src/sys/psMemory.c
- Timestamp:
- Sep 8, 2004, 11:06:00 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/sys/psMemory.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sys/psMemory.c
r1715 r1730 9 9 * @author Robert Lupton, Princeton University 10 10 * 11 * @version $Revision: 1.3 6$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-09-08 00:15:16$11 * @version $Revision: 1.37 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-09-08 21:06:00 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 28 28 29 29 #include "psSysUtilsErrors.h" 30 #define ERRORNAME_PREFIX PS_ERRORNAME_DOMAIN ".psMemory."31 30 32 31 #define P_PS_MEMMAGIC (void *)0xdeadbeef // Magic number in psMemBlock header … … 103 102 { 104 103 if (ptr->refCounter < 1) { 105 psErrorMsg( ERRORNAME_PREFIX"memProblemCallbackDefault", false, PS_ERR_MEMORY_CORRUPTION,104 psErrorMsg(PS_ERRORNAME_DOMAIN "memProblemCallbackDefault", false, PS_ERR_MEMORY_CORRUPTION, 106 105 PS_ERRORTEXT_psMemory_MULTIPLE_FREE, 107 106 ptr->id, ptr->file, ptr->lineno, file, lineno); … … 231 230 232 231 if (m == NULL) { 233 psErrorMsg( ERRORNAME_PREFIX"checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,232 psErrorMsg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION, 234 233 PS_ERRORTEXT_psMemory_NULL_BLOCK); 235 234 return 1; … … 238 237 if (m->refCounter == 0) { 239 238 // using an unreferenced block of memory, are you? 240 psErrorMsg( ERRORNAME_PREFIX"checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,239 psErrorMsg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION, 241 240 PS_ERRORTEXT_psMemory_DEREF_BLOCK_USE, 242 241 m->id); … … 245 244 246 245 if (m->startblock != P_PS_MEMMAGIC || m->endblock != P_PS_MEMMAGIC) { 247 psErrorMsg( ERRORNAME_PREFIX"checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,246 psErrorMsg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION, 248 247 PS_ERRORTEXT_psMemory_UNDERFLOW, 249 248 m->id); … … 251 250 } 252 251 if (*(void **)((int8_t *) (m + 1) + m->userMemorySize) != P_PS_MEMMAGIC) { 253 psErrorMsg( ERRORNAME_PREFIX"checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION,252 psErrorMsg(PS_ERRORNAME_DOMAIN "checkMemBlock", true, PS_ERR_MEMORY_CORRUPTION, 254 253 PS_ERRORTEXT_psMemory_OVERFLOW, 255 254 m->id); … … 419 418 void p_psFree(void *vptr, const char *file, int lineno) 420 419 { 420 if (vptr == NULL) { 421 return; 422 } 423 psMemBlock* ptr = ((psMemBlock* ) vptr) - 1; 424 if (ptr->refCounter < 1) { 425 psMemBlock* ptr = ((psMemBlock* ) vptr) - 1; 426 427 psErrorMsg(PS_ERRORNAME_DOMAIN "psFree",PS_ERR_MEMORY_DEREF_USAGE,true, 428 PS_ERRORTEXT_psMemory_MULTIPLE_FREE, 429 ptr->id, ptr->file, ptr->lineno, file, lineno); 430 431 return; 432 } 421 433 (void)p_psMemDecrRefCounter(vptr, file, lineno); // this handles the free, if required. 422 434 } … … 535 547 536 548 if (ptr->refCounter > 1) { 537 // / XXX - Probably should have another mutex here.538 549 ptr->refCounter--; // multiple references, just decrement the count. 539 550 pthread_mutex_unlock(&ptr->refCounterMutex);
Note:
See TracChangeset
for help on using the changeset viewer.
