forked from osmocom/wireshark
Expose the new wmem API functions, and use a consistent order of
alloc/free/realloc across all of wmem. svn path=/trunk/; revision=47548
This commit is contained in:
parent
eea6cb6315
commit
b636b88646
|
@ -43,8 +43,8 @@ struct _wmem_allocator_t {
|
|||
|
||||
/* Consumer functions */
|
||||
void *(*alloc)(void *private_data, const size_t size);
|
||||
void *(*realloc)(void *private_data, void *ptr, const size_t size);
|
||||
void (*free)(void *private_data, void *ptr);
|
||||
void *(*realloc)(void *private_data, void *ptr, const size_t size);
|
||||
|
||||
/* Producer/Manager functions */
|
||||
void (*free_all)(void *private_data);
|
||||
|
|
|
@ -55,6 +55,18 @@ wmem_simple_alloc(void *private_data, const size_t size)
|
|||
return buf;
|
||||
}
|
||||
|
||||
static void
|
||||
wmem_simple_free(void *private_data, void *ptr)
|
||||
{
|
||||
wmem_simple_allocator_t *allocator;
|
||||
|
||||
allocator = (wmem_simple_allocator_t*) private_data;
|
||||
|
||||
/* remove() takes care of calling g_free() for us since we set up the
|
||||
* hash table with g_hash_table_new_full() */
|
||||
g_hash_table_remove(allocator->block_table, ptr);
|
||||
}
|
||||
|
||||
static void *
|
||||
wmem_simple_realloc(void *private_data, void *ptr, const size_t size)
|
||||
{
|
||||
|
@ -77,18 +89,6 @@ wmem_simple_realloc(void *private_data, void *ptr, const size_t size)
|
|||
return newptr;
|
||||
}
|
||||
|
||||
static void
|
||||
wmem_simple_free(void *private_data, void *ptr)
|
||||
{
|
||||
wmem_simple_allocator_t *allocator;
|
||||
|
||||
allocator = (wmem_simple_allocator_t*) private_data;
|
||||
|
||||
/* remove() takes care of calling g_free() for us since we set up the
|
||||
* hash table with g_hash_table_new_full() */
|
||||
g_hash_table_remove(allocator->block_table, ptr);
|
||||
}
|
||||
|
||||
static void
|
||||
wmem_simple_free_all(void *private_data)
|
||||
{
|
||||
|
|
|
@ -44,15 +44,26 @@ typedef struct _wmem_allocator_t wmem_allocator_t;
|
|||
|
||||
void *
|
||||
wmem_alloc(wmem_allocator_t *allocator, const size_t size);
|
||||
#define wmem_new(allocator, type) ((type*)wmem_alloc((allocator), sizeof(type)))
|
||||
#define wmem_new(allocator, type) \
|
||||
((type*)wmem_alloc((allocator), sizeof(type)))
|
||||
|
||||
void *
|
||||
wmem_alloc0(wmem_allocator_t *allocator, const size_t size);
|
||||
#define wmem_new0(allocator, type) ((type*)wmem_alloc0((allocator), sizeof(type)))
|
||||
#define wmem_new0(allocator, type) \
|
||||
((type*)wmem_alloc0((allocator), sizeof(type)))
|
||||
|
||||
void
|
||||
wmem_free(wmem_allocator_t *allocator, void *ptr);
|
||||
|
||||
void *
|
||||
wmem_realloc(wmem_allocator_t *allocator, void *ptr, const size_t size);
|
||||
|
||||
void
|
||||
wmem_free_all(wmem_allocator_t *allocator);
|
||||
|
||||
void
|
||||
wmem_gc(wmem_allocator_t *allocator);
|
||||
|
||||
void
|
||||
wmem_destroy_allocator(wmem_allocator_t *allocator);
|
||||
|
||||
|
|
Loading…
Reference in New Issue