Changeset 14676 for trunk/psLib/src/sys/psMemory.c
- Timestamp:
- Aug 27, 2007, 1:14:35 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/sys/psMemory.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sys/psMemory.c
r12886 r14676 10 10 * @author Joshua Hoblitt, University of Hawaii 11 11 * 12 * @version $Revision: 1.9 6$ $Name: not supported by cvs2svn $13 * @date $Date: 2007-0 4-18 19:38:10$12 * @version $Revision: 1.97 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2007-08-27 23:14:35 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 374 374 MUTEX_UNLOCK(&memBlockListMutex); 375 375 PS_MEM_ABORT(__func__, "Detected memory corruption"); 376 return nbad;377 376 } 378 377 } … … 383 382 384 383 return nbad; 384 } 385 386 bool p_psMemIsAlloced(const char *file, 387 unsigned int lineno, 388 const char *func, 389 const void *ptr) 390 { 391 // if ptr is a psAlloc()'d memory, find the actual address of the memBlock 392 psMemBlock *addr = ((psMemBlock *)ptr) - 1; 393 394 // get exclusive access to the memBlock list to avoid it changing on us 395 // while we use it. 396 MUTEX_LOCK(&memBlockListMutex); 397 398 // loop through the linked list of memBlocks looking for a matching pointer 399 for (psMemBlock *memBlock = lastMemBlockAllocated; memBlock != NULL; memBlock = memBlock->nextBlock) { 400 if (memBlock == addr) { 401 // we found the memBlock 402 HANDLE_BAD_BLOCK(memBlock, file, lineno, func); 403 404 MUTEX_UNLOCK(&memBlockListMutex); 405 return true; 406 } 407 } 408 409 // release the lock on the memblock list 410 MUTEX_UNLOCK(&memBlockListMutex); 411 412 return false; 385 413 } 386 414
Note:
See TracChangeset
for help on using the changeset viewer.
