From 882d179fc83b5e9073f4eb4b57a5a4dc4138de94 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Tue, 2 Jan 2007 21:25:20 +0200 Subject: [PATCH] Make many string parameters const in the memory leak detector. --- src/util/memdebug.c | 30 +++++++++++++++--------------- src/util/memdebug.h | 10 +++++----- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/util/memdebug.c b/src/util/memdebug.c index 26c653807..612a91565 100644 --- a/src/util/memdebug.c +++ b/src/util/memdebug.c @@ -114,7 +114,7 @@ struct alloc_header { #endif int size; int line; - unsigned char *file; + const unsigned char *file; unsigned char *comment; #ifdef CHECK_XFLOWS @@ -167,8 +167,8 @@ INIT_LIST_HEAD(memory_list); #ifdef LOG_MEMORY_ALLOC static void -dump_short_info(struct alloc_header *ah, unsigned char *file, int line, - unsigned char *type) +dump_short_info(struct alloc_header *ah, const unsigned char *file, int line, + const unsigned char *type) { fprintf(stderr, "%p", PTR_AH2BASE(ah)), fflush(stderr); fprintf(stderr, ":%d", ah->size), fflush(stderr); @@ -184,8 +184,8 @@ dump_short_info(struct alloc_header *ah, unsigned char *file, int line, #endif static void -dump_info(struct alloc_header *ah, unsigned char *info, - unsigned char *file, int line, unsigned char *type) +dump_info(struct alloc_header *ah, const unsigned char *info, + const unsigned char *file, int line, const unsigned char *type) { fprintf(stderr, "%p", PTR_AH2BASE(ah)); fflush(stderr); /* In some extreme cases, we may core here, as 'ah' can no longer point @@ -213,8 +213,8 @@ dump_info(struct alloc_header *ah, unsigned char *info, #ifdef CHECK_AH_SANITY static inline int -bad_ah_sanity(struct alloc_header *ah, unsigned char *info, - unsigned char *file, int line) +bad_ah_sanity(struct alloc_header *ah, const unsigned char *info, + const unsigned char *file, int line) { if (!ah) return 1; if (ah->magic != AH_SANITY_MAGIC) { @@ -228,8 +228,8 @@ bad_ah_sanity(struct alloc_header *ah, unsigned char *info, #ifdef CHECK_XFLOWS static inline int -bad_xflow_magic(struct alloc_header *ah, unsigned char *info, - unsigned char *file, int line) +bad_xflow_magic(struct alloc_header *ah, const unsigned char *info, + const unsigned char *file, int line) { if (!ah) return 1; @@ -282,7 +282,7 @@ check_memory_leaks(void) static int alloc_try = 0; static int -patience(unsigned char *file, int line, unsigned char *of) +patience(const unsigned char *file, int line, const unsigned char *of) { errfile = file; errline = line; @@ -310,7 +310,7 @@ patience(unsigned char *file, int line, unsigned char *of) } void * -debug_mem_alloc(unsigned char *file, int line, size_t size) +debug_mem_alloc(const unsigned char *file, int line, size_t size) { struct alloc_header *ah; size_t true_size; @@ -354,7 +354,7 @@ debug_mem_alloc(unsigned char *file, int line, size_t size) } void * -debug_mem_calloc(unsigned char *file, int line, size_t eltcount, size_t eltsize) +debug_mem_calloc(const unsigned char *file, int line, size_t eltcount, size_t eltsize) { struct alloc_header *ah; size_t size = eltcount * eltsize; @@ -405,7 +405,7 @@ debug_mem_calloc(unsigned char *file, int line, size_t eltcount, size_t eltsize) } void -debug_mem_free(unsigned char *file, int line, void *ptr) +debug_mem_free(const unsigned char *file, int line, void *ptr) { struct alloc_header *ah; int ok = 1; @@ -485,7 +485,7 @@ debug_mem_free(unsigned char *file, int line, void *ptr) } void * -debug_mem_realloc(unsigned char *file, int line, void *ptr, size_t size) +debug_mem_realloc(const unsigned char *file, int line, void *ptr, size_t size) { struct alloc_header *ah, *ah2; size_t true_size; @@ -558,7 +558,7 @@ debug_mem_realloc(unsigned char *file, int line, void *ptr, size_t size) } void -set_mem_comment(void *ptr, unsigned char *str, int len) +set_mem_comment(void *ptr, const unsigned char *str, int len) { struct alloc_header *ah; diff --git a/src/util/memdebug.h b/src/util/memdebug.h index 3917be4fc..bcccd41a5 100644 --- a/src/util/memdebug.h +++ b/src/util/memdebug.h @@ -12,11 +12,11 @@ struct mem_stats { extern struct mem_stats mem_stats; -void *debug_mem_alloc(unsigned char *, int, size_t); -void *debug_mem_calloc(unsigned char *, int, size_t, size_t); -void debug_mem_free(unsigned char *, int, void *); -void *debug_mem_realloc(unsigned char *, int, void *, size_t); -void set_mem_comment(void *, unsigned char *, int); +void *debug_mem_alloc(const unsigned char *, int, size_t); +void *debug_mem_calloc(const unsigned char *, int, size_t, size_t); +void debug_mem_free(const unsigned char *, int, void *); +void *debug_mem_realloc(const unsigned char *, int, void *, size_t); +void set_mem_comment(void *, const unsigned char *, int); void check_memory_leaks(void);