diff --git a/lib/arena.c b/lib/arena.c index a8d7569ee..cb6928a29 100644 --- a/lib/arena.c +++ b/lib/arena.c @@ -2,9 +2,11 @@ #include "helpers.h" -// set to 0 for alloc debugging, e.g. through valgrind #define ARENA_MIN_PIECE_LEN 4096 +// enable to perform each allocation separately, to make debugging (valgrind...) easier +//#define ARENA_ALLOC_DEBUG + struct arena_piece { char *tail; size_t left; @@ -17,7 +19,9 @@ static struct arena_piece *arena_piece_new(size_t size, void *(*alloc_fn)(size_t struct arena_piece *ret; size_t alloc_size = size + sizeof(*ret) + ARENA_ALLOC_ALIGN; +#ifndef ARENA_ALLOC_DEBUG alloc_size = MAX(alloc_size, ARENA_MIN_PIECE_LEN); +#endif ret = alloc_fn(alloc_size); if (!ret) return NULL; diff --git a/lib/bencode.c b/lib/bencode.c index de3f9a832..6fe8190eb 100644 --- a/lib/bencode.c +++ b/lib/bencode.c @@ -11,6 +11,9 @@ #include "helpers.h" +// enable to perform each allocation separately, to make debugging (valgrind...) easier +//#define BENCODE_ALLOC_DEBUG + #define BENCODE_HASH_BUCKETS 31 /* prime numbers work best */ struct __bencode_hash {