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:
parent
916cb86723
commit
7c750db580
@ -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>
|
2000-11-22 Hrvoje Niksic <hniksic@arsdigita.com>
|
||||||
|
|
||||||
* ftp.c (getftp): ftp_getaddress() returns a malloc'ed copy of the
|
* ftp.c (getftp): ftp_getaddress() returns a malloc'ed copy of the
|
||||||
|
16
src/utils.c
16
src/utils.c
@ -119,7 +119,13 @@ memfatal (const char *what)
|
|||||||
|
|
||||||
Each of the *_debug function does its magic and calls the real one. */
|
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)
|
xmalloc_real (size_t size)
|
||||||
{
|
{
|
||||||
void *ptr = malloc (size);
|
void *ptr = malloc (size);
|
||||||
@ -128,13 +134,13 @@ xmalloc_real (size_t size)
|
|||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
STATIC_IF_DEBUG void
|
||||||
xfree_real (void *ptr)
|
xfree_real (void *ptr)
|
||||||
{
|
{
|
||||||
free (ptr);
|
free (ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
STATIC_IF_DEBUG void *
|
||||||
xrealloc_real (void *ptr, size_t newsize)
|
xrealloc_real (void *ptr, size_t newsize)
|
||||||
{
|
{
|
||||||
void *newptr;
|
void *newptr;
|
||||||
@ -151,7 +157,7 @@ xrealloc_real (void *ptr, size_t newsize)
|
|||||||
return newptr;
|
return newptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
STATIC_IF_DEBUG char *
|
||||||
xstrdup_real (const char *s)
|
xstrdup_real (const char *s)
|
||||||
{
|
{
|
||||||
char *copy;
|
char *copy;
|
||||||
@ -285,7 +291,7 @@ xrealloc_debug (void *ptr, size_t newsize, const char *source_file, int source_l
|
|||||||
++malloc_count;
|
++malloc_count;
|
||||||
register_ptr (newptr, source_file, source_line);
|
register_ptr (newptr, source_file, source_line);
|
||||||
}
|
}
|
||||||
else
|
else if (newptr != ptr)
|
||||||
{
|
{
|
||||||
unregister_ptr (ptr);
|
unregister_ptr (ptr);
|
||||||
register_ptr (newptr, source_file, source_line);
|
register_ptr (newptr, source_file, source_line);
|
||||||
|
Loading…
Reference in New Issue
Block a user