summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert James Kaes <rjkaes@users.sourceforge.net>2001-09-11 19:27:27 +0000
committerRobert James Kaes <rjkaes@users.sourceforge.net>2001-09-11 19:27:27 +0000
commite2f10bc2ea6f2fdfeb23f0cbbac1d65ada1b9936 (patch)
tree34a40932d10690ab738e282038e4b108e730c1da
parent2c3cc9185dc25af31c3b76501302ce0c06f8da7e (diff)
downloadtinyproxy-e2f10bc2ea6f2fdfeb23f0cbbac1d65ada1b9936.tar.gz
tinyproxy-e2f10bc2ea6f2fdfeb23f0cbbac1d65ada1b9936.zip
Added the debugging realloc() function.
Diffstat (limited to '')
-rw-r--r--src/utils.c9
-rw-r--r--src/utils.h5
2 files changed, 12 insertions, 2 deletions
diff --git a/src/utils.c b/src/utils.c
index 7d9a872..d9361d6 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -1,4 +1,4 @@
-/* $Id: utils.c,v 1.10 2001-09-08 18:55:58 rjkaes Exp $
+/* $Id: utils.c,v 1.11 2001-09-11 19:27:27 rjkaes Exp $
*
* Misc. routines which are used by the various functions to handle strings
* and memory allocation and pretty much anything else we can think of. Also,
@@ -49,6 +49,13 @@ void *debugging_malloc(size_t size, const char *file, unsigned long line)
return ptr;
}
+void *debugging_realloc(void *ptr, size_t size, const char *file, unsigned long line)
+{
+ void *newptr = realloc(ptr, size);
+ fprintf(stderr, "{realloc: %p -> %p:%u} %s:%lu\n", ptr, newptr, size, file, line);
+ return newptr;
+}
+
void debugging_free(void *ptr, const char *file, unsigned long line)
{
fprintf(stderr, "{free: %p} %s:%lu\n", ptr, file, line);
diff --git a/src/utils.h b/src/utils.h
index 24b7758..409def9 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -1,4 +1,4 @@
-/* $Id: utils.h,v 1.7 2001-09-08 18:55:58 rjkaes Exp $
+/* $Id: utils.h,v 1.8 2001-09-11 19:27:27 rjkaes Exp $
*
* See 'utils.h' for a detailed description.
*
@@ -42,13 +42,16 @@ extern size_t strlcpy(char *dst, const char *src, size_t size);
extern void *debugging_calloc(size_t nmemb, size_t size, const char *file, unsigned long line);
extern void *debugging_malloc(size_t size, const char *file, unsigned long line);
extern void debugging_free(void *ptr, const char *file, unsigned long line);
+extern void *debugging_realloc(void *ptr, size_t size, const char *file, unsigned long line);
# define safecalloc(x, y) debugging_calloc(x, y, __FILE__, __LINE__)
# define safemalloc(x) debugging_malloc(x, __FILE__, __LINE__)
+# define saferealloc(x, y) debugging_realloc(x, y, __FILE__, __LINE__)
# define safefree(x) debugging_free(x, __FILE__, __LINE__)
#else
# define safecalloc(x, y) calloc(x, y)
# define safemalloc(x) malloc(x)
+# define saferealloc(x, y) realloc(x, y)
# define safefree(x) free(x)
#endif