From 57ee958611625c7355581fe3b921245f683d9efd Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Mon, 7 Sep 2026 10:40:15 -0400 Subject: [PATCH] MT#55283 use dedicated flag for arena debugging Change-Id: Ic5d99add7dbea68cf8a167103857c2de2686be7c --- lib/arena.c | 6 +++++- lib/bencode.c | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) 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 {