From 43909ed3514b4354e92e2f9119dec6fd7902fc0c Mon Sep 17 00:00:00 2001 From: cazfi Date: Tue, 8 Nov 2016 17:37:30 +0000 Subject: [PATCH] sanity_check_size() memory allocations on debug builds only. See patch #7951 git-svn-id: svn://svn.gna.org/svn/freeciv/branches/S2_6@34445 a0f10bec-cc02-0410-94fc-a9cfff90b4cd --- utility/mem.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/utility/mem.c b/utility/mem.c index d44f33798f..66e81ef2ea 100644 --- a/utility/mem.c +++ b/utility/mem.c @@ -43,6 +43,7 @@ static void handle_alloc_failure(size_t size, const char *called_as, exit(EXIT_FAILURE); } +#ifdef FREECIV_DEBUG /**************************************************************************** Check the size for sanity. The program will exit rather than allocate a dangerously large amount of memory. @@ -61,7 +62,7 @@ static void sanity_check_size(size_t size, const char *called_as, called_as, (unsigned long) size, line, file); } } - +#endif /* FREECIV_DEBUG */ /******************************************************************************* Function used by fc_malloc macro, malloc() replacement @@ -74,7 +75,9 @@ void *fc_real_malloc(size_t size, { void *ptr; +#ifdef FREECIV_DEBUG sanity_check_size(size, called_as, line, file); +#endif /* FREECIV_DEBUG */ /* Some systems return NULL on malloc(0) * According to ANSI C, the return is implementation-specific, @@ -104,7 +107,9 @@ void *fc_real_realloc(void *ptr, size_t size, return fc_real_malloc(size, called_as, line, file); } +#ifdef FREECIV_DEBUG sanity_check_size(size, called_as, line, file); +#endif /* FREECIV_DEBUG */ new_ptr = realloc(ptr, size); if (!new_ptr) { -- 2.11.4.GIT