]> sjero.net Git - wget/commitdiff
[svn] More memory debug tweaks.
authorhniksic <devnull@localhost>
Thu, 23 Nov 2000 21:44:56 +0000 (13:44 -0800)
committerhniksic <devnull@localhost>
Thu, 23 Nov 2000 21:44:56 +0000 (13:44 -0800)
Published in <sxs4s0z2bwi.fsf@florida.arsdigita.de>.

src/ChangeLog
src/utils.c

index 8f30490cb00d66254dacae5ed5311a3d6af73e54..12ddf71111041fe58e846d4a37c8a20bb3aa18f5 100644 (file)
@@ -1,3 +1,12 @@
+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
index ecf944c3b57c147a8ad8dae58aaa5e6284e04e64..b59125aaa2fc164fb32d027b7ba046dd2c1abac1 100644 (file)
@@ -119,7 +119,13 @@ memfatal (const char *what)
 
    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);
@@ -128,13 +134,13 @@ xmalloc_real (size_t 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;
@@ -151,7 +157,7 @@ xrealloc_real (void *ptr, size_t newsize)
   return newptr;
 }
 
-char *
+STATIC_IF_DEBUG char *
 xstrdup_real (const char *s)
 {
   char *copy;
@@ -285,7 +291,7 @@ xrealloc_debug (void *ptr, size_t newsize, const char *source_file, int source_l
       ++malloc_count;
       register_ptr (newptr, source_file, source_line);
     }
-  else
+  else if (newptr != ptr)
     {
       unregister_ptr (ptr);
       register_ptr (newptr, source_file, source_line);