aboutsummaryrefslogtreecommitdiffstats
path: root/Source/charon/allocator.h
diff options
context:
space:
mode:
authorJan Hutter <jhutter@hsr.ch>2005-11-10 15:28:47 +0000
committerJan Hutter <jhutter@hsr.ch>2005-11-10 15:28:47 +0000
commit1473b8f6c935e07d88b8319dd0088b573faf4ee7 (patch)
tree0f13dab114382f7abb3c6ec042934f2e900055dc /Source/charon/allocator.h
parent0617722caee6c75c6b066f4f018d80779342dc21 (diff)
downloadstrongswan-1473b8f6c935e07d88b8319dd0088b573faf4ee7.tar.bz2
strongswan-1473b8f6c935e07d88b8319dd0088b573faf4ee7.tar.xz
- replaced long macros with functions
Diffstat (limited to 'Source/charon/allocator.h')
-rw-r--r--Source/charon/allocator.h23
1 files changed, 6 insertions, 17 deletions
diff --git a/Source/charon/allocator.h b/Source/charon/allocator.h
index fdc2b1f9e..e0611b843 100644
--- a/Source/charon/allocator.h
+++ b/Source/charon/allocator.h
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <stddef.h>
+#include <string.h>
#include "types.h"
@@ -210,25 +211,13 @@
#define report_memory_leaks(void) (global_allocator->report_memory_leaks(global_allocator))
#else
#define allocator_alloc(bytes) (malloc(bytes))
- #define allocator_alloc_as_chunk(bytes){\
- chunk_t new_chunk; \
- new_chunk.ptr = malloc(bytes); \
- new_chunk.len = (new_chunk.ptr == NULL) ? 0 : bytes; \
- return new_chunk; \
- }
+
+ chunk_t allocator_alloc_as_chunk(size_t bytes);
+
#define allocator_realloc(old,bytes) (realloc(old,bytes))
#define allocator_free(pointer) (free(pointer))
- #define allocator_clone_bytes(pointer,size){\
- void *new_data = malloc(size)\
- if (new_data == NULL) return NULL; \
- memcpy(new_data,pointer,size)\
- return new_data; \
- }
- #define allocator_free_chunk(chunk){ \
- free(chunk.ptr); \
- chunk.ptr = NULL; \
- chunk.len = 0; \
- }
+ void * allocator_clone_bytes(void * pointer, size_t size);
+ void allocator_free_chunk(chunk_t chunk);
#define report_memory_leaks(void) {}
#endif