changed to prototype of qse_mmgr_t function to accept mmgr itself instead of mmgr->ctx and fixed a memory leak bug under a certain failure condition

This commit is contained in:
2014-07-09 15:01:16 +00:00
parent 36b20b4169
commit 82a639045f
10 changed files with 100 additions and 41 deletions

View File

@ -90,17 +90,17 @@ protected:
///
/// bridge function from the #qse_mmgr_t type the allocMem() function.
///
static void* alloc_mem (void* ctx, size_t n);
static void* alloc_mem (mmgr_t* mmgr, size_t n);
///
/// bridge function from the #qse_mmgr_t type the reallocMem() function.
///
static void* realloc_mem (void* ctx, void* ptr, size_t n);
static void* realloc_mem (mmgr_t* mmgr, void* ptr, size_t n);
///
/// bridge function from the #qse_mmgr_t type the freeMem() function.
///
static void free_mem (void* ctx, void* ptr);
static void free_mem (mmgr_t* mmgr, void* ptr);
};
/////////////////////////////////

View File

@ -42,18 +42,18 @@
* The QSE_MMGR_ALLOC() macro allocates a memory block of the @a size bytes
* using the @a mmgr memory manager.
*/
#define QSE_MMGR_ALLOC(mmgr,size) ((mmgr)->alloc((mmgr)->ctx,size))
#define QSE_MMGR_ALLOC(mmgr,size) ((mmgr)->alloc(mmgr,size))
/**
* The QSE_MMGR_REALLOC() macro resizes a memory block pointed to by @a ptr
* to the @a size bytes using the @a mmgr memory manager.
*/
#define QSE_MMGR_REALLOC(mmgr,ptr,size) ((mmgr)->realloc((mmgr)->ctx,ptr,size))
#define QSE_MMGR_REALLOC(mmgr,ptr,size) ((mmgr)->realloc(mmgr,ptr,size))
/**
* The QSE_MMGR_FREE() macro deallocates the memory block pointed to by @a ptr.
*/
#define QSE_MMGR_FREE(mmgr,ptr) ((mmgr)->free((mmgr)->ctx,ptr))
#define QSE_MMGR_FREE(mmgr,ptr) ((mmgr)->free(mmgr,ptr))
#ifdef __cplusplus
extern "C" {