#include <stdio.h>
#include <stdlib.h>
-#ifdef HAVE_STRING_H
-# include <string.h>
-#else /* not HAVE_STRING_H */
-# include <strings.h>
-#endif /* not HAVE_STRING_H */
-#include <sys/types.h>
+#include <string.h>
#include <errno.h>
#include <assert.h>
#include "xmalloc.h"
#include "hash.h" /* for hash_pointer */
-#ifndef errno
-extern int errno;
-#endif
-
/* This file implements several wrappers around the basic allocation
routines. This is done for two reasons: first, so that the callers
of these functions need not check for errors, which is easy to
malloc_count, free_count, malloc_count - free_count);
for (i = 0; i < SZ; i++)
if (malloc_table[i].ptr != NULL)
- printf ("0x%0*lx: %s:%d\n", 2 * sizeof (void *),
- (long) malloc_table[i].ptr,
+ printf ("0x%0*lx: %s:%d\n", PTR_FORMAT (malloc_table[i].ptr),
malloc_table[i].file, malloc_table[i].line);
}
if (!unregister_ptr (ptr))
{
fprintf (stderr, "%s: bad xfree(%0*lx) at %s:%d\n",
- exec_name, 2 * sizeof (void *), (long) ptr,
- source_file, source_line);
+ exec_name, PTR_FORMAT (ptr), source_file, source_line);
abort ();
}
++free_count;