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:
@ -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);
|
||||
};
|
||||
|
||||
/////////////////////////////////
|
||||
|
@ -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" {
|
||||
|
@ -654,20 +654,23 @@ struct qse_xptl_t
|
||||
};
|
||||
typedef struct qse_xptl_t qse_xptl_t;
|
||||
|
||||
|
||||
typedef struct qse_mmgr_t qse_mmgr_t;
|
||||
|
||||
/**
|
||||
* allocate a memory chunk of the size @a n.
|
||||
* @return pointer to a memory chunk on success, QSE_NULL on failure.
|
||||
*/
|
||||
typedef void* (*qse_mmgr_alloc_t) (void* ctx, qse_size_t n);
|
||||
typedef void* (*qse_mmgr_alloc_t) (qse_mmgr_t* mmgr, qse_size_t n);
|
||||
/**
|
||||
* resize a memory chunk pointed to by @a ptr to the size @a n.
|
||||
* @return pointer to a memory chunk on success, QSE_NULL on failure.
|
||||
*/
|
||||
typedef void* (*qse_mmgr_realloc_t) (void* ctx, void* ptr, qse_size_t n);
|
||||
typedef void* (*qse_mmgr_realloc_t) (qse_mmgr_t* mmgr, void* ptr, qse_size_t n);
|
||||
/**
|
||||
* free a memory chunk pointed to by @a ptr.
|
||||
*/
|
||||
typedef void (*qse_mmgr_free_t) (void* ctx, void* ptr);
|
||||
typedef void (*qse_mmgr_free_t) (qse_mmgr_t* mmgr, void* ptr);
|
||||
|
||||
/**
|
||||
* The qse_mmgr_t type defines the memory management interface.
|
||||
@ -687,7 +690,6 @@ struct qse_mmgr_t
|
||||
qse_mmgr_free_t free; /**< disposal function */
|
||||
void* ctx; /**< user-defined data pointer */
|
||||
};
|
||||
typedef struct qse_mmgr_t qse_mmgr_t;
|
||||
|
||||
typedef qse_size_t (*qse_cmgr_mbtowc_t) (
|
||||
const qse_mchar_t* mb,
|
||||
|
Reference in New Issue
Block a user