Changeset 257 for trunk/archive/pslib/include/psMemory.h
- Timestamp:
- Mar 18, 2004, 9:37:58 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/archive/pslib/include/psMemory.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/archive/pslib/include/psMemory.h
r247 r257 6 6 * \ingroup SystemGroup 7 7 */ 8 9 // Structures *********************************************************** 8 10 9 11 /** Book-keeping data for storage allocator. … … 21 23 } psMemBlock; 22 24 23 / ** prototype of a basic callback used by memory functions */25 /// prototype of a basic callback used by memory functions 24 26 typedef int (*psMemCallback)(const psMemBlock *ptr); 25 27 26 / ** prototype of a callback used in error conditions */28 /// prototype of a callback used in error conditions 27 29 typedef void (*psMemProblemCallback)(const psMemBlock *ptr, const char *file, int lineno); 28 30 29 / ** prototype of a callback used when memory runs out */31 /// prototype of a callback used when memory runs out 30 32 typedef void *(*psMemExhaustedCallback)(size_t size); 31 33 32 /*****************************************************************************/ 34 /** Functions **************************************************************/ 35 /** \addtogroup SystemGroup System Utilities 36 * \{ 37 */ 33 38 34 / ** Memory allocation. Underlying private function called by macro psAlloc. */39 /// Memory allocation. Underlying private function called by macro psAlloc. 35 40 void *p_psAlloc(size_t size, //!< Size required 36 41 const char *file, //!< File of call 37 int lineno //!< Line number of call38 );42 int lineno) //!< Line number of call 43 ; 39 44 40 / ** Memory re-allocation. Underlying private function called by macro psRealloc. */45 /// Memory re-allocation. Underlying private function called by macro psRealloc. 41 46 void *p_psRealloc(void *ptr, //!< Pointer to re-allocate 42 47 size_t size, //!< Size required 43 48 const char *file, //!< File of call 44 int lineno //!< Line number of call45 );49 int lineno) //!< Line number of call 50 ; 46 51 47 / ** Free memory. Underlying private function called by macro psFree. */52 /// Free memory. Underlying private function called by macro psFree. 48 53 void p_psFree(void *ptr, //!< Pointer to free 49 54 const char *file, //!< File of call 50 int lineno //!< Line number of call51 );55 int lineno) //!< Line number of call 56 ; 52 57 53 /** Memory allocation. psAlloc sends file and line number to p_psAlloc. */ 58 /// Check for memory leaks 59 int psMemCheckLeaks(int id0, //!< don't list blocks with id < id0 60 psMemBlock ***arr, //!< pointer to array of pointers to leaked blocks, or NULL 61 FILE *fd) //!< print list of leaks to fd (or NULL) 62 ; 63 64 /// Check for memory corruption 65 int psMemCheckCorruption(int abort_on_error) //!< Abort on detecting corruption? 66 ; 67 68 /// Return reference counter 69 int psMemGetRefCounter(void *vptr) //!< Pointer to get refCounter for 70 ; 71 72 /// Increment reference counter and return the pointer 73 void *psMemIncrRefCounter(void *vptr) //!< Pointer to increment refCounter, and return 74 ; 75 76 /// Decrement reference counter and return the pointer 77 void *psMemDecrRefCounter(void *vptr) //!< Pointer to decrement refCounter, and return 78 ; 79 80 /// Set callback for problems 81 psMemProblemCallback psMemProblemSetCB(psMemProblemCallback func) //!< Function to run 82 ; 83 84 /// Set callback for out-of-memory 85 psMemExhaustedCallback psMemExhaustedSetCB(psMemExhaustedCallback func) //!< Function to run 86 ; 87 88 /// Set call back for when a particular memory block is allocated 89 psMemCallback psMemAllocateSetCB(psMemCallback func) 90 ; 91 92 /// Set call back for when a particular memory block is freed 93 psMemCallback psMemFreeSetCB(psMemCallback func) 94 ; 95 96 /// get next memory ID 97 int psMemGetId(void) 98 ; 99 100 /// set p_psMemAllocateID to id 101 long psMemSetAllocateID(long id) 102 ; 103 104 /// set p_psMemFreeID to id 105 long psMemSetFreeID(long id) 106 ; 107 108 /* \} */ // End of SystemGroup Functions 109 110 /// Memory allocation. psAlloc sends file and line number to p_psAlloc. 54 111 #define psAlloc(size) p_psAlloc(size, __FILE__, __LINE__) 55 112 56 / ** Memory re-allocation. psRealloc sends file and line number to p_psRealloc. */113 /// Memory re-allocation. psRealloc sends file and line number to p_psRealloc. 57 114 #define psRealloc(ptr, size) p_psRealloc(ptr, size, __FILE__, __LINE__) 58 115 59 / ** Free memory. psFree sends file and line number to p_psFree. */116 /// Free memory. psFree sends file and line number to p_psFree. 60 117 #define psFree(size) p_psFree(size, __FILE__, __LINE__) 61 118 62 / ** prevent the use of 'malloc'. malloc is re-defined to throw an error in the C preprocessor */119 /// prevent the use of 'malloc'. malloc is re-defined to throw an error in the C preprocessor 63 120 #define malloc(S) for 64 121 65 / ** prevent the use of 'realloc'. realloc is re-defined to throw an error in the C preprocessor */122 /// prevent the use of 'realloc'. realloc is re-defined to throw an error in the C preprocessor 66 123 #define realloc(P,S) for 67 124 68 / ** prevent the use of 'free'. free is re-defined to throw an error in the C preprocessor */125 /// prevent the use of 'free'. free is re-defined to throw an error in the C preprocessor 69 126 #define free(P) for 70 127 71 /*****************************************************************************/72 /** Check for memory leaks */73 int psMemCheckLeaks(int id0, //!< don't list blocks with id < id074 psMemBlock ***arr, //!< pointer to array of pointers to leaked blocks, or NULL75 FILE *fd //!< print list of leaks to fd (or NULL)76 );77 78 /** Check for memory corruption */79 int psMemCheckCorruption(int abort_on_error //!< Abort on detecting corruption?80 );81 82 /*****************************************************************************/83 84 /** Return reference counter */85 int psMemGetRefCounter(void *vptr //!< Pointer to get refCounter for86 );87 /** Increment reference counter and return the pointer */88 void *psMemIncrRefCounter(void *vptr //!< Pointer to increment refCounter, and return89 );90 /** Decrement reference counter and return the pointer */91 void *psMemDecrRefCounter(void *vptr //!< Pointer to decrement refCounter, and return92 );93 94 /*****************************************************************************/95 /*96 * Functions to set and control callbacks97 */98 99 /** Set callback for problems */100 psMemProblemCallback psMemProblemSetCB(psMemProblemCallback func //!< Function to run101 );102 psMemExhaustedCallback psMemExhaustedSetCB(psMemExhaustedCallback func); //!< set call back for exhausted103 //!< memory104 105 psMemCallback psMemAllocateSetCB(psMemCallback func); //!< Set call back for when a particular memory block is106 //!< allocated107 psMemCallback psMemFreeSetCB(psMemCallback func); //!< set call back for when a particular memory block is108 //!< freed109 110 int psMemGetId(void); //!< get next memory ID111 long psMemSetAllocateID(long id); //!< set p_psMemAllocateID to id112 long psMemSetFreeID(long id); //!< set p_psMemFreeID to id113 114 128 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
