37 lines
1.1 KiB
C
37 lines
1.1 KiB
C
/**
|
|
* @file re_mem.h Interface to Memory management with reference counting
|
|
*
|
|
* Copyright (C) 2010 Creytiv.com
|
|
*/
|
|
|
|
|
|
/**
|
|
* Defines the memory destructor handler, which is called when the reference
|
|
* of a memory object goes down to zero
|
|
*
|
|
* @param data Pointer to memory object
|
|
*/
|
|
typedef void (mem_destroy_h)(void *data);
|
|
|
|
/** Memory Statistics */
|
|
struct memstat {
|
|
size_t bytes_cur; /**< Current bytes allocated */
|
|
size_t bytes_peak; /**< Peak bytes allocated */
|
|
size_t blocks_cur; /**< Current blocks allocated */
|
|
size_t blocks_peak; /**< Peak blocks allocated */
|
|
size_t size_min; /**< Lowest block size allocated */
|
|
size_t size_max; /**< Largest block size allocated */
|
|
};
|
|
|
|
void *mem_alloc(size_t size, mem_destroy_h *dh);
|
|
void *mem_zalloc(size_t size, mem_destroy_h *dh);
|
|
void *mem_realloc(void *data, size_t size);
|
|
void *mem_ref(void *data);
|
|
void *mem_deref(void *data);
|
|
uint32_t mem_nrefs(const void *data);
|
|
|
|
void mem_debug(void);
|
|
void mem_threshold_set(ssize_t n);
|
|
struct re_printf;
|
|
int mem_status(struct re_printf *pf, void *unused);
|
|
int mem_get_stat(struct memstat *mstat);
|