aboutsummaryrefslogtreecommitdiff
path: root/src/util/common_allocation.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2012-08-29 17:03:16 +0000
committerBart Polot <bart@net.in.tum.de>2012-08-29 17:03:16 +0000
commit308eab2402422262d9b895f98008a4d5b176be59 (patch)
treef68a6d824cc7b23ce9df45a3fc14732a0625752b /src/util/common_allocation.c
parent3f8a19f31a2458b639f12a0f31eb182d5c524c18 (diff)
downloadgnunet-308eab2402422262d9b895f98008a4d5b176be59.tar.gz
gnunet-308eab2402422262d9b895f98008a4d5b176be59.zip
- Fix memory posioning on OS X (MSIZE is pre-defined to 256, doesnt HAVE_MALLOC_USABLE_MEMORY -> compile error)
Diffstat (limited to 'src/util/common_allocation.c')
-rw-r--r--src/util/common_allocation.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/util/common_allocation.c b/src/util/common_allocation.c
index 90af6e091..ab8715a6d 100644
--- a/src/util/common_allocation.c
+++ b/src/util/common_allocation.c
@@ -28,6 +28,9 @@
28#if HAVE_MALLOC_H 28#if HAVE_MALLOC_H
29#include <malloc.h> 29#include <malloc.h>
30#endif 30#endif
31#if HAVE_MALLOC_MALLOC_H
32#include <malloc/malloc.h>
33#endif
31 34
32#define LOG(kind,...) GNUNET_log_from (kind, "util",__VA_ARGS__) 35#define LOG(kind,...) GNUNET_log_from (kind, "util",__VA_ARGS__)
33 36
@@ -192,10 +195,12 @@ GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename, int linenumber)
192#endif 195#endif
193 196
194#if WINDOWS 197#if WINDOWS
195#define MSIZE(p) _msize (p) 198#define M_SIZE(p) _msize (p)
196#endif 199#endif
197#if HAVE_MALLOC_USABLE_SIZE 200#if HAVE_MALLOC_USABLE_SIZE
198#define MSIZE(p) malloc_usable_size (p) 201#define M_SIZE(p) malloc_usable_size (p)
202#elif HAVE_MALLOC_SIZE
203#define M_SIZE(p) malloc_size (p)
199#endif 204#endif
200 205
201/** 206/**
@@ -214,12 +219,12 @@ GNUNET_xfree_ (void *ptr, const char *filename, int linenumber)
214 ptr = &((size_t *) ptr)[-1]; 219 ptr = &((size_t *) ptr)[-1];
215 mem_used -= *((size_t *) ptr); 220 mem_used -= *((size_t *) ptr);
216#endif 221#endif
217#if defined(MSIZE) 222#if defined(M_SIZE)
218#if ENABLE_POISONING 223#if ENABLE_POISONING
219 { 224 {
220 size_t i; 225 size_t i;
221 char baadfood[5] = BAADFOOD_STR; 226 char baadfood[5] = BAADFOOD_STR;
222 size_t s = MSIZE (ptr); 227 size_t s = M_SIZE (ptr);
223 for (i = 0; i < s; i++) 228 for (i = 0; i < s; i++)
224 ((char *) ptr)[i] = baadfood[i % 4]; 229 ((char *) ptr)[i] = baadfood[i % 4];
225 } 230 }