56 lines
2.1 KiB
C
56 lines
2.1 KiB
C
#ifndef INCLUDED_C_MEMORY_H
|
|||
|
|
#define INCLUDED_C_MEMORY_H
|
||
|
|
|
||
|
|
#ifndef INCLUDED_C_TYPES_H
|
||
|
|
#include <c_Types.h>
|
||
|
|
#endif /*INCLUDED_C_TYPES_H*/
|
||
|
|
|
||
|
|
#ifndef INCLUDED_C_ALIGNMENT_H
|
||
|
|
#include <c_Alignment.h>
|
||
|
|
#endif /*INCLUDED_C_ALIGNMENT_H*/
|
||
|
|
|
||
|
|
#ifndef INCLUDED_ASSERT_H
|
||
|
|
#define INCLUDED_ASSERT_H
|
||
|
|
#include <assert.h>
|
||
|
|
#endif /*INCLUDED_ASSERT_H*/
|
||
|
|
|
||
|
|
|
||
|
|
/* ------------------------------------------------------------------------------------------------------------------ */
|
||
|
|
/* */
|
||
|
|
|
||
|
|
void* c_Memory_Alloc(c_size_t nBytes, const char* file, int line);
|
||
|
|
void* c_Memory_Calloc(c_size_t nCount, c_size_t nBytes, const char* file, int line);
|
||
|
|
void* c_Memory_Realloc(void* ptr, c_size_t nBytes, const char* file, int line);
|
||
|
|
void c_Memory_Free(void* ptr, const char* file, int line);
|
||
|
|
|
||
|
|
void* c_Memory_Aligned_Alloc(c_size_t alignment, c_size_t nBytes, const char* file, int line);
|
||
|
|
void* c_Memory_Aligned_Calloc(c_size_t alignment, c_size_t num, c_size_t size, const char* file, int line);
|
||
|
|
void* c_Memory_Aligned_Realloc(size_t alignment, void* ptr, size_t new_size, const char* file, int line);
|
||
|
|
void c_Memory_Aligned_Free(void* ptr, const char* file, int line);
|
||
|
|
|
||
|
|
/* ------------------------------------------------------------------------------------------------------------------ */
|
||
|
|
/* */
|
||
|
|
|
||
|
|
#if !defined(NDEBUG) && defined(C_MEMORY_CHECK_ENABLE)
|
||
|
|
c_size_t c_memory_leak_report(void);
|
||
|
|
void c_memory_tracker_reset(void);
|
||
|
|
#endif
|
||
|
|
|
||
|
|
|
||
|
|
/* ------------------------------------------------------------------------------------------------------------------ */
|
||
|
|
/* */
|
||
|
|
|
||
|
|
#define C_ALLOC(nbytes) c_Memory_Alloc(nbytes, __FILE__, __LINE__)
|
||
|
|
#define C_CALLOC(count, nbytes) c_Memory_Calloc(count, nbytes, __FILE__, __LINE__)
|
||
|
|
#define C_REALLOC(ptr, nbytes) c_Memory_Realloc(ptr, nbytes, __FILE__, __LINE__)
|
||
|
|
#define C_FREE(p) (c_Memory_Free((p), __FILE__, __LINE__), (p)=0)
|
||
|
|
|
||
|
|
#define C_NEW(p) ((p) = C_ALLOC(sizeof(*(p))))
|
||
|
|
#define C_NEW0(p) ((p)=C_CALLOC(1, sizeof(*(p))))
|
||
|
|
#define C_RESIZE(p, nbytes) ((p)=C_REALLOC((p), (nbytes)))
|
||
|
|
|
||
|
|
#define C_ALIGNED_ALLOC(align, nbytes) c_Memory_Aligned_Alloc((align), (nbytes), __FILE__, __LINE__)
|
||
|
|
#define C_ALIGNED_FREE(p) (c_Memory_Aligned_Free((p), __FILE__, __LINE__), (p)=0)
|
||
|
|
|
||
|
|
#endif /*INCLUDED_C_MEMORY_H*/
|