1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

[svn] More memory debug tweaks.

Published in <sxs4s0z2bwi.fsf@florida.arsdigita.de>.
This commit is contained in:
hniksic 2000-11-23 13:44:56 -08:00
parent 916cb86723
commit 7c750db580
2 changed files with 20 additions and 5 deletions

View 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

View 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);