diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2021-10-11 23:28:17 +0200 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2021-10-11 23:28:17 +0200 |
commit | 65554324abf7e83e3f0f51c3b059e621934afb9d (patch) | |
tree | 051c0240b9418559f1b125b6918db77ab08b7f60 /src/util/common_allocation.c | |
parent | 41e8c1e21238afa238f43433d4e77a8249886728 (diff) | |
download | gnunet-65554324abf7e83e3f0f51c3b059e621934afb9d.tar.gz gnunet-65554324abf7e83e3f0f51c3b059e621934afb9d.zip |
BUILD: Remove W32 ifdef
Diffstat (limited to 'src/util/common_allocation.c')
-rw-r--r-- | src/util/common_allocation.c | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/src/util/common_allocation.c b/src/util/common_allocation.c index 308488131..f48f87167 100644 --- a/src/util/common_allocation.c +++ b/src/util/common_allocation.c | |||
@@ -42,13 +42,6 @@ | |||
42 | #define INT_MAX 0x7FFFFFFF | 42 | #define INT_MAX 0x7FFFFFFF |
43 | #endif | 43 | #endif |
44 | 44 | ||
45 | #if 0 | ||
46 | #define W32_MEM_LIMIT 200000000 | ||
47 | #endif | ||
48 | |||
49 | #ifdef W32_MEM_LIMIT | ||
50 | static LONG mem_used = 0; | ||
51 | #endif | ||
52 | 45 | ||
53 | /** | 46 | /** |
54 | * Allocate memory. Checks the return value, aborts if no more | 47 | * Allocate memory. Checks the return value, aborts if no more |
@@ -184,11 +177,6 @@ GNUNET_xmemdup_ (const void *buf, | |||
184 | /* As a security precaution, we generally do not allow very large | 177 | /* As a security precaution, we generally do not allow very large |
185 | * allocations here */ | 178 | * allocations here */ |
186 | GNUNET_assert_at (size <= GNUNET_MAX_MALLOC_CHECKED, filename, linenumber); | 179 | GNUNET_assert_at (size <= GNUNET_MAX_MALLOC_CHECKED, filename, linenumber); |
187 | #ifdef W32_MEM_LIMIT | ||
188 | size += sizeof(size_t); | ||
189 | if (mem_used + size > W32_MEM_LIMIT) | ||
190 | return NULL; | ||
191 | #endif | ||
192 | GNUNET_assert_at (size < INT_MAX, filename, linenumber); | 180 | GNUNET_assert_at (size < INT_MAX, filename, linenumber); |
193 | ret = malloc (size); | 181 | ret = malloc (size); |
194 | if (ret == NULL) | 182 | if (ret == NULL) |
@@ -196,11 +184,6 @@ GNUNET_xmemdup_ (const void *buf, | |||
196 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "malloc"); | 184 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "malloc"); |
197 | GNUNET_assert (0); | 185 | GNUNET_assert (0); |
198 | } | 186 | } |
199 | #ifdef W32_MEM_LIMIT | ||
200 | *((size_t *) ret) = size; | ||
201 | ret = &((size_t *) ret)[1]; | ||
202 | mem_used += size; | ||
203 | #endif | ||
204 | GNUNET_memcpy (ret, buf, size); | 187 | GNUNET_memcpy (ret, buf, size); |
205 | return ret; | 188 | return ret; |
206 | } | 189 | } |
@@ -222,23 +205,12 @@ GNUNET_xmalloc_unchecked_ (size_t size, const char *filename, int linenumber) | |||
222 | 205 | ||
223 | (void) filename; | 206 | (void) filename; |
224 | (void) linenumber; | 207 | (void) linenumber; |
225 | #ifdef W32_MEM_LIMIT | ||
226 | size += sizeof(size_t); | ||
227 | if (mem_used + size > W32_MEM_LIMIT) | ||
228 | return NULL; | ||
229 | #endif | ||
230 | 208 | ||
231 | result = malloc (size); | 209 | result = malloc (size); |
232 | if (NULL == result) | 210 | if (NULL == result) |
233 | return NULL; | 211 | return NULL; |
234 | memset (result, 0, size); | 212 | memset (result, 0, size); |
235 | 213 | ||
236 | #ifdef W32_MEM_LIMIT | ||
237 | *((size_t *) result) = size; | ||
238 | result = &((size_t *) result)[1]; | ||
239 | mem_used += size; | ||
240 | #endif | ||
241 | |||
242 | return result; | 214 | return result; |
243 | } | 215 | } |
244 | 216 | ||
@@ -260,11 +232,6 @@ GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename, int linenumber) | |||
260 | (void) filename; | 232 | (void) filename; |
261 | (void) linenumber; | 233 | (void) linenumber; |
262 | 234 | ||
263 | #ifdef W32_MEM_LIMIT | ||
264 | n += sizeof(size_t); | ||
265 | ptr = &((size_t *) ptr)[-1]; | ||
266 | mem_used = mem_used - *((size_t *) ptr) + n; | ||
267 | #endif | ||
268 | #if defined(M_SIZE) | 235 | #if defined(M_SIZE) |
269 | #if ENABLE_POISONING | 236 | #if ENABLE_POISONING |
270 | { | 237 | { |
@@ -295,9 +262,6 @@ GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename, int linenumber) | |||
295 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "realloc"); | 262 | LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "realloc"); |
296 | GNUNET_assert (0); | 263 | GNUNET_assert (0); |
297 | } | 264 | } |
298 | #ifdef W32_MEM_LIMIT | ||
299 | ptr = &((size_t *) ptr)[1]; | ||
300 | #endif | ||
301 | return ptr; | 265 | return ptr; |
302 | } | 266 | } |
303 | 267 | ||
@@ -333,10 +297,6 @@ GNUNET_xfree_ (void *ptr, | |||
333 | { | 297 | { |
334 | if (NULL == ptr) | 298 | if (NULL == ptr) |
335 | return; | 299 | return; |
336 | #ifdef W32_MEM_LIMIT | ||
337 | ptr = &((size_t *) ptr)[-1]; | ||
338 | mem_used -= *((size_t *) ptr); | ||
339 | #endif | ||
340 | #if defined(M_SIZE) | 300 | #if defined(M_SIZE) |
341 | #if ENABLE_POISONING | 301 | #if ENABLE_POISONING |
342 | { | 302 | { |