+2000-11-23 Hrvoje Niksic <hniksic@arsdigita.com>
+
+ * utils.c (xrealloc_debug): Do the unregister/register thing only
+ if the pointer has actually changed.
+ (xmalloc_real): Declare `static' in DEBUG_MALLOC builds.
+ (xfree_real): Ditto.
+ (xrealloc_real): Ditto.
+ (xstrdup_real): Ditto.
+
2000-11-22 Hrvoje Niksic <hniksic@arsdigita.com>
* ftp.c (getftp): ftp_getaddress() returns a malloc'ed copy of the
Each of the *_debug function does its magic and calls the real one. */
-void *
+#ifdef DEBUG_MALLOC
+# define STATIC_IF_DEBUG static
+#else
+# define STATIC_IF_DEBUG
+#endif
+
+STATIC_IF_DEBUG void *
xmalloc_real (size_t size)
{
void *ptr = malloc (size);
return ptr;
}
-void
+STATIC_IF_DEBUG void
xfree_real (void *ptr)
{
free (ptr);
}
-void *
+STATIC_IF_DEBUG void *
xrealloc_real (void *ptr, size_t newsize)
{
void *newptr;
return newptr;
}
-char *
+STATIC_IF_DEBUG char *
xstrdup_real (const char *s)
{
char *copy;
++malloc_count;
register_ptr (newptr, source_file, source_line);
}
- else
+ else if (newptr != ptr)
{
unregister_ptr (ptr);
register_ptr (newptr, source_file, source_line);