Changes in src/memoryallocator.hpp [f66195:7218f8]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/memoryallocator.hpp
-
Property mode
changed from
100644
to100755
rf66195 r7218f8 55 55 template <> char* Malloc<char>(size_t size, const char* output); 56 56 57 /* *Allocates a memory range using calloc().57 /* Allocates a memory range using calloc(). 58 58 * Prints the provided error message in case of a failure. 59 59 * … … 61 61 * \param failure message which is printed if the allocation fails 62 62 * \return pointer to the allocated memory range, will be NULL if a failure occurred 63 63 */ 64 64 template <typename X> X* Calloc(size_t size, const char* output) 65 65 { 66 66 X* buffer = NULL; 67 buffer = (X*) calloc(size of(X) * size, (size_t) 0);67 buffer = (X*) calloc(size, sizeof(X)); 68 68 69 69 if (buffer != NULL) { … … 76 76 return buffer; 77 77 }; 78 78 79 79 80 /** Reallocates a memory range using realloc(). If the provided pointer to the old … … 105 106 }; 106 107 107 /** Frees allocated memory range using free() .108 /** Frees allocated memory range using free(), NULL'ing \a **buffer. 108 109 * 109 * \param pointer to the allocated memory range to free; may be NULL, this function is a no-op then110 * \param **buffer to the allocated memory range to free; may be NULL, this function is a no-op then 110 111 * \param *msg optional error message 111 112 */ … … 115 116 return; 116 117 117 MemoryUsageObserver::getInstance()->removeMemory(*buffer );118 MemoryUsageObserver::getInstance()->removeMemory(*buffer, msg); 118 119 free(*buffer); 119 120 *buffer = NULL; 120 121 }; 121 122 123 /** Frees allocated memory range using free() for ... * const \a buffer types. 124 * 125 * \param *buffer to the allocated memory range to free; may be NULL, this function is a no-op then 126 * \param *msg optional error message 127 */ 128 template <typename X> void Free(X* const buffer, const char *msg = NULL) 129 { 130 if ((buffer == NULL)) 131 return; 132 133 MemoryUsageObserver::getInstance()->removeMemory(buffer, msg); 134 free(buffer); 135 }; 136 122 137 #endif /*MEMORYALLOCATOR_HPP_*/ -
Property mode
changed from
Note:
See TracChangeset
for help on using the changeset viewer.