diff options
author | Jan Hutter <jhutter@hsr.ch> | 2005-11-16 14:44:25 +0000 |
---|---|---|
committer | Jan Hutter <jhutter@hsr.ch> | 2005-11-16 14:44:25 +0000 |
commit | d5fc0f731d2eb6dcc11e680b2e77890b7ba01725 (patch) | |
tree | 5b6a97e1a40cef0e790634eb38d9465a2be74e64 /Source/charon/utils | |
parent | df917df71c69cd4764c84c3888e25fd2f385fdcc (diff) | |
download | strongswan-d5fc0f731d2eb6dcc11e680b2e77890b7ba01725.tar.bz2 strongswan-d5fc0f731d2eb6dcc11e680b2e77890b7ba01725.tar.xz |
- tried to fix memory errors
Diffstat (limited to 'Source/charon/utils')
-rw-r--r-- | Source/charon/utils/allocator.c | 15 | ||||
-rw-r--r-- | Source/charon/utils/allocator.h | 7 |
2 files changed, 13 insertions, 9 deletions
diff --git a/Source/charon/utils/allocator.c b/Source/charon/utils/allocator.c index 290b1de3b..4c65bbbf0 100644 --- a/Source/charon/utils/allocator.c +++ b/Source/charon/utils/allocator.c @@ -112,18 +112,18 @@ struct private_allocator_s */ static void *allocate_special(private_allocator_t *this,size_t bytes, char * file,int line, bool use_mutex) { - memory_hdr_t *allocated_memory = malloc(sizeof(memory_hdr_t) + bytes); - - if (allocated_memory == NULL) + memory_hdr_t *allocated_memory = malloc(sizeof(memory_hdr_t) + bytes);; + + if (allocated_memory == NULL) { return allocated_memory; } - + if (use_mutex) { pthread_mutex_lock( &(this->mutex)); } - + allocated_memory->info.line = line; allocated_memory->info.filename = file; allocated_memory->info.size_of_memory = bytes; @@ -326,6 +326,11 @@ chunk_t allocator_alloc_as_chunk(size_t bytes) } +void * allocator_realloc(void * old, size_t newsize) +{ + return realloc(old,newsize); +} + void * allocator_clone_bytes(void * pointer, size_t size) { void *data; diff --git a/Source/charon/utils/allocator.h b/Source/charon/utils/allocator.h index ab8f59bfd..8006911e7 100644 --- a/Source/charon/utils/allocator.h +++ b/Source/charon/utils/allocator.h @@ -209,11 +209,10 @@ */ #define report_memory_leaks(void) (global_allocator->report_memory_leaks(global_allocator)) #else - #define allocator_alloc(bytes) (malloc(bytes)) - + + #define allocator_alloc(bytes) (malloc(bytes)) chunk_t allocator_alloc_as_chunk(size_t bytes); - - #define allocator_realloc(old,bytes) (realloc(old,bytes)) + void * allocator_realloc(void * old, size_t newsize); #define allocator_free(pointer) (free(pointer)) void * allocator_clone_bytes(void * pointer, size_t size); void allocator_free_chunk(chunk_t chunk); |