
#ifdef __cplusplus
}
#endif

/*
 * alloc macros to provide for memory FILE/LINE debugging information.
 */

#ifndef DMALLOC_DISABLE

#undef malloc
#define malloc(size) \
  dmalloc_malloc(__FILE__, __LINE__, (size), DMALLOC_FUNC_MALLOC, 0, 0)
#undef calloc
#define calloc(count, size) \
  dmalloc_malloc(__FILE__, __LINE__, (count)*(size), DMALLOC_FUNC_CALLOC, 0, 0)
#undef realloc
#define realloc(ptr, size) \
  dmalloc_realloc(__FILE__, __LINE__, (ptr), (size), DMALLOC_FUNC_REALLOC, 0)
#undef recalloc
#define recalloc(ptr, size) \
  dmalloc_realloc(__FILE__, __LINE__, (ptr), (size), DMALLOC_FUNC_RECALLOC, 0)
#undef memalign
#define memalign(alignment, size) \
  dmalloc_malloc(__FILE__, __LINE__, (size), DMALLOC_FUNC_MEMALIGN, \
		 (alignment), 0 /* no xalloc */)
#undef valloc
#define valloc(size) \
  dmalloc_malloc(__FILE__, __LINE__, (size), DMALLOC_FUNC_VALLOC, \
		0 /* special case */, 0 /* no xalloc */)
#ifndef DMALLOC_STRDUP_MACRO
#undef strdup
#define strdup(str) \
  dmalloc_strndup(__FILE__, __LINE__, (str), -1, 0)
#endif
#ifndef DMALLOC_STRNDUP_MACRO
#undef strndup
#define strndup(str, len) \
  dmalloc_strndup(__FILE__, __LINE__, (str), (len), 0)
#endif
#undef free
#define free(ptr) \
  dmalloc_free(__FILE__, __LINE__, (ptr), DMALLOC_FUNC_FREE)

#undef xmalloc
#define xmalloc(size) \
  dmalloc_malloc(__FILE__, __LINE__, (size), DMALLOC_FUNC_MALLOC, 0, 1)
#undef xcalloc
#define xcalloc(count, size) \
  dmalloc_malloc(__FILE__, __LINE__, (count)*(size), DMALLOC_FUNC_CALLOC, 0, 1)
#undef xrealloc
#define xrealloc(ptr, size) \
  dmalloc_realloc(__FILE__, __LINE__, (ptr), (size), DMALLOC_FUNC_REALLOC, 1)
#undef xrecalloc
#define xrecalloc(ptr, size) \
  dmalloc_realloc(__FILE__, __LINE__, (ptr), (size), DMALLOC_FUNC_RECALLOC, 1)
#undef xmemalign
#define xmemalign(alignment, size) \
  dmalloc_malloc(__FILE__, __LINE__, (size), DMALLOC_FUNC_MEMALIGN, \
		 (alignment), 1)
#undef xvalloc
#define xvalloc(size) \
  dmalloc_malloc(__FILE__, __LINE__, (size), DMALLOC_FUNC_VALLOC, 0, 1)
#undef xstrdup
#define xstrdup(str) \
  dmalloc_strndup(__FILE__, __LINE__, (str), -1, 1)
#undef xstrndup
#define xstrndup(str, len) \
  dmalloc_strndup(__FILE__, __LINE__, (str), (len), 1)
#undef xfree
#define xfree(ptr) \
  dmalloc_free(__FILE__, __LINE__, (ptr), DMALLOC_FUNC_FREE)

#ifdef DMALLOC_FUNC_CHECK

/*
 * do debugging on the following functions.  this may cause compilation or
 * other problems depending on your architecture.
 */
#undef atoi
#define atoi(str) \
  _dmalloc_atoi(__FILE__, __LINE__, (str))
#undef atol
#define atol(str) \
  _dmalloc_atol(__FILE__, __LINE__, (str))

#undef bcmp
#define bcmp(b1, b2, len) \
  _dmalloc_bcmp(__FILE__, __LINE__, (b1), (b2), (len))
#undef bcopy
#define bcopy(from, to, len) \
  _dmalloc_bcopy(__FILE__, __LINE__, (from), (to), (len))
#undef bzero
#define bzero(buf, len) \
  _dmalloc_bzero(__FILE__, __LINE__, (buf), (len))

#undef memcmp
#define memcmp(b1, b2, len) \
  _dmalloc_memcmp(__FILE__, __LINE__, (b1), (b2), (len))
#undef memcpy
#define memcpy(to, from, len) \
  _dmalloc_memcpy(__FILE__, __LINE__, (to), (from), (len))
#undef memmove
#define memmove(to, from, len) \
  _dmalloc_memmove(__FILE__, __LINE__, (to), (from), (len))
#undef memset
#define memset(buf, ch, len) \
  _dmalloc_memset(__FILE__, __LINE__, (buf), (ch), (len))

#undef index
#define index(str, ch) \
  _dmalloc_index(__FILE__, __LINE__, (str), (ch))
#undef rindex
#define rindex(str, ch) \
  _dmalloc_rindex(__FILE__, __LINE__, (str), (ch))

#undef strcat
#define strcat(to, from) \
  _dmalloc_strcat(__FILE__, __LINE__, (to), (from))
#undef strcmp
#define strcmp(s1, s2) \
  _dmalloc_strcmp(__FILE__, __LINE__, (s1), (s2))
#undef strlen
#define strlen(str) \
  _dmalloc_strlen(__FILE__, __LINE__, (str))
#undef strtok
#define strtok(str, sep) \
  _dmalloc_strtok(__FILE__, __LINE__, (str), (sep))

#undef memccpy
#define memccpy(s1, s2, ch, len) \
  _dmalloc_memccpy(__FILE__, __LINE__, (s1), (s2),(ch),(len))
#undef memchr
#define memchr(s1, ch, len) \
  _dmalloc_memchr(__FILE__, __LINE__, (s1), (ch), (len))

#undef strchr
#define strchr(str, ch) \
  _dmalloc_strchr(__FILE__, __LINE__, (str), (ch))
#undef strrchr
#define strrchr(str, ch) \
  _dmalloc_strrchr(__FILE__, __LINE__, (str), (ch))

#undef strcpy
#define strcpy(to, from) \
  _dmalloc_strcpy(__FILE__, __LINE__, (to), (from))
#undef strncpy
#define strncpy(to, from, len) \
  _dmalloc_strncpy(__FILE__, __LINE__, (to), (from), (len))
#undef strcasecmp
#define strcasecmp(s1, s2) \
  _dmalloc_strcasecmp(__FILE__, __LINE__, (s1), (s2))
#undef strncasecmp
#define strncasecmp(s1, s2, len) \
  _dmalloc_strncasecmp(__FILE__, __LINE__, (s1), (s2), (len))
#undef strspn
#define strspn(str, list) \
  _dmalloc_strspn(__FILE__, __LINE__, (str), (list))
#undef strcspn
#define strcspn(str, list) \
  _dmalloc_strcspn(__FILE__, __LINE__, (str), (list))
#undef strncat
#define strncat(to, from, len) \
  _dmalloc_strncat(__FILE__, __LINE__, (to), (from), (len))
#undef strncmp
#define strncmp(s1, s2, len) \
  _dmalloc_strncmp(__FILE__, __LINE__, (s1), (s2), (len))
#undef strpbrk
#define strpbrk(str, list) \
  _dmalloc_strpbrk(__FILE__, __LINE__, (str), (list))
#undef strstr
#define strstr(str, pat) \
  _dmalloc_strstr(__FILE__, __LINE__, (str), (pat))

#endif /* DMALLOC_FUNC_CHECK */
#endif /* ! DMALLOC_DISABLE */

/*
 * feel free to add your favorite functions here and to arg_check.[ch]
 */

#ifdef __cplusplus
extern "C" {
#endif

