Changeset 369
- Timestamp:
- Mar 31, 2004, 11:55:47 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/archive/pslib/include/psMemory.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/archive/pslib/include/psMemory.h
r344 r369 16 16 */ 17 17 typedef struct { 18 const void * magic0;///< initialised to p_psMEMMAGIC18 const void *startblock; ///< initialised to p_psMEMMAGIC 19 19 const unsigned long id; ///< a unique ID for this allocation 20 20 const char *file; ///< set from __FILE__ in e.g. p_psAlloc 21 21 const int lineno; ///< set from __LINE__ in e.g. p_psAlloc 22 22 int refCounter; ///< how many times pointer is referenced 23 const void *magic; ///< initialised to p_psMEMMAGIC 23 const void **endpost; ///< initialised to p_psMEMMAGIC 24 const void *endblock; ///< initialised to p_psMEMMAGIC 24 25 } psMemBlock; 25 26 26 27 /// prototype of a basic callback used by memory functions 27 typedef int (*psMemCallback)(const psMemBlock *ptr); 28 typedef long (*psMemAllocateCB)(const psMemBlock *ptr); 29 30 /// prototype of memory free callback used by memory functions 31 typedef long (*psMemFreeCB)(const psMemBlock *ptr); 28 32 29 33 /// prototype of a callback used in error conditions 30 typedef void (*psMemProblemC allback)(const psMemBlock *ptr, const char *file, int lineno);34 typedef void (*psMemProblemCB)(const psMemBlock *ptr, const char *file, int lineno); 31 35 32 36 /// prototype of a callback used when memory runs out 33 typedef void *(*psMemExhaustedC allback)(size_t size);37 typedef void *(*psMemExhaustedCB)(size_t size); 34 38 35 39 /** Functions **************************************************************/ … … 41 45 void *p_psAlloc(size_t size, ///< Size required 42 46 const char *file, ///< File of call 43 int lineno ///< Line number of call44 );47 int lineno) ///< Line number of call 48 ; 45 49 46 50 /// Memory re-allocation. Underlying private function called by macro psRealloc. … … 48 52 size_t size, ///< Size required 49 53 const char *file, ///< File of call 50 int lineno ///< Line number of call51 );54 int lineno) ///< Line number of call 55 ; 52 56 53 57 /// Free memory. Underlying private function called by macro psFree. 54 58 void p_psFree(void *ptr, ///< Pointer to free 55 59 const char *file, ///< File of call 56 int lineno ///< Line number of call57 );60 int lineno) ///< Line number of call 61 ; 58 62 59 63 /// Check for memory leaks 60 64 int psMemCheckLeaks(int id0, ///< don't list blocks with id < id0 61 65 psMemBlock ***arr, ///< pointer to array of pointers to leaked blocks, or NULL 62 FILE *fd ///< print list of leaks to fd (or NULL)63 );66 FILE *fd) ///< print list of leaks to fd (or NULL) 67 ; 64 68 65 69 /// Check for memory corruption 66 int psMemCheckCorruption(int abort_on_error ///< Abort on detecting corruption?67 );70 int psMemCheckCorruption(int abort_on_error) ///< Abort on detecting corruption? 71 ; 68 72 69 73 /// Return reference counter 70 int psMemGetRefCounter(void *vptr ///< Pointer to get refCounter for71 );74 int psMemGetRefCounter(void *vptr) ///< Pointer to get refCounter for 75 ; 72 76 73 77 /// Increment reference counter and return the pointer 74 void *psMemIncrRefCounter(void *vptr ///< Pointer to increment refCounter, and return75 );78 void *psMemIncrRefCounter(void *vptr) ///< Pointer to increment refCounter, and return 79 ; 76 80 77 81 /// Decrement reference counter and return the pointer 78 void *psMemDecrRefCounter(void *vptr ///< Pointer to decrement refCounter, and return79 );82 void *psMemDecrRefCounter(void *vptr) ///< Pointer to decrement refCounter, and return 83 ; 80 84 81 85 /// Set callback for problems 82 psMemProblemC allback psMemProblemSetCB(psMemProblemCallback func///< Function to run83 );86 psMemProblemCB psMemProblemCBSet(psMemProblemCB func) ///< Function to run 87 ; 84 88 85 89 /// Set callback for out-of-memory 86 psMemExhaustedC allback psMemExhaustedSetCB(psMemExhaustedCallback func///< Function to run87 );90 psMemExhaustedCB psMemExhaustedCBSet(psMemExhaustedCB func) ///< Function to run 91 ; 88 92 89 93 /// Set call back for when a particular memory block is allocated 90 psMemC allback psMemAllocateSetCB(psMemCallback func///< Function to run91 );94 psMemCB psMemAllocateCBSet(psMemAllocateCB func) ///< Function to run 95 ; 92 96 93 97 /// Set call back for when a particular memory block is freed 94 psMemC allback psMemFreeSetCB(psMemCallback func95 );98 psMemCB psMemFreeCBSet(psMemFreeCB func) ///< Function to run 99 ; 96 100 97 101 /// get next memory ID 98 int psMemGetId(void); 102 int psMemGetId(void) 103 ; 99 104 100 105 /// set p_psMemAllocateID to id 101 long psMem SetAllocateID(long id///< ID to set102 );106 long psMemAllocateIDSet(long id) ///< ID to set 107 ; 103 108 104 109 /// set p_psMemFreeID to id 105 long psMem SetFreeID(long id///< ID to set106 );110 long psMemFreeIDSet(long id) ///< ID to set 111 ; 107 112 108 113 /* \} */ // End of SystemGroup Functions
Note:
See TracChangeset
for help on using the changeset viewer.
