Clapkit
Loading...
Searching...
No Matches
ckMemory.h File Reference
#include "ckUtils.h"
#include "dlmalloc.h"
#include <Memory.h>
#include <cstddef>

Go to the source code of this file.

Macros

#define CKMalloc(sz)   __CKMalloc(__func__, __LINE__, __FILENAME__, (sz))
 Use instead of malloc.
 
#define CKFree(ptr)   __CKFree(__func__, __LINE__, __FILENAME__, (ptr))
 Use instead of free.
 
#define CKNew   new (__func__, __LINE__, __FILENAME__)
 Use instead of new.
 
#define CKDelete(ptr)   __CKDestroy(ptr, __FILENAME__, __func__, __LINE__)
 Use instead of delete.
 
#define CKNewArray   new (__func__, __LINE__, __FILENAME__)
 
#define CKDeleteArray(ptr, count)    __CKDestroyArray(ptr, (count), __FILENAME__, __func__, __LINE__)
 
#define CKSafeCopyString(dest, src)   __CKSafeCopyString(&dest, src, __func__, __LINE__, __FILENAME__)
 Copy a string (if it is a string) to a destination. Free the destination if there is already something there.
 

Functions

bool __CKSafeCopyString (char **dest, const char *src, const char *func=0, int line=0, const char *file=0)
 
void CKMemoryUsage (size_t *totalAllocd, size_t *totalFreed, int *numOfPtrs)
 
void CKMemoryDumpLeaks ()
 
void * __CKMalloc (const char *func, int line, const char *file, size_t size)
 
void __CKFree (const char *func, int line, const char *file, void *ptr)
 
void * __CKNew (const char *func, int line, const char *file, size_t size)
 
void __CKDelete (void *ptr, const char *func, int line, const char *file)
 
template<typename T >
void __CKDestroy (T *ptr, const char *file, const char *func, int line) noexcept
 
template<typename T >
void __CKDestroyArray (T *ptr, int count, const char *file, const char *func, int line) noexcept
 
void * operator new (size_t size, const char *func, int line, const char *file)
 
void * operator new[] (size_t size, const char *func, int line, const char *file)
 

Macro Definition Documentation

◆ CKDeleteArray

#define CKDeleteArray (   ptr,
  count 
)     __CKDestroyArray(ptr, (count), __FILENAME__, __func__, __LINE__)

◆ CKNewArray

#define CKNewArray   new (__func__, __LINE__, __FILENAME__)

Function Documentation

◆ __CKDelete()

void __CKDelete ( void *  ptr,
const char *  func,
int  line,
const char *  file 
)

Wrapper for delete used to find potential leaks.

◆ __CKDestroy()

template<typename T >
void __CKDestroy ( T *  ptr,
const char *  file,
const char *  func,
int  line 
)
inlinenoexcept

◆ __CKDestroyArray()

template<typename T >
void __CKDestroyArray ( T *  ptr,
int  count,
const char *  file,
const char *  func,
int  line 
)
inlinenoexcept

◆ __CKFree()

void __CKFree ( const char *  func,
int  line,
const char *  file,
void *  ptr 
)

◆ __CKMalloc()

void * __CKMalloc ( const char *  func,
int  line,
const char *  file,
size_t  size 
)

Wrapper for malloc used to find potential leaks.

◆ __CKNew()

void * __CKNew ( const char *  func,
int  line,
const char *  file,
size_t  size 
)

Wrapper for new used to find potential leaks.

◆ __CKSafeCopyString()

bool __CKSafeCopyString ( char **  dest,
const char *  src,
const char *  func = 0,
int  line = 0,
const char *  file = 0 
)

◆ CKMemoryDumpLeaks()

void CKMemoryDumpLeaks ( )

(Try to) print all the leaks to the console.

◆ CKMemoryUsage()

void CKMemoryUsage ( size_t *  _totalAllocd,
size_t *  _totalFreed,
int *  _numOfPtrs 
)

Return the stats about memory usage.

◆ operator new()

void * operator new ( size_t  size,
const char *  func,
int  line,
const char *  file 
)
inline

◆ operator new[]()

void * operator new[] ( size_t  size,
const char *  func,
int  line,
const char *  file 
)
inline