/* $Id: util.h,v 1.6 1999/06/09 11:31:32 levitte Exp $ */

#ifndef _UTIL_H

#include <stdio.h>
#include <sys/types.h>

/* We know, it's not safe, but we know how to use it correctly. */
#define min(a,b) ((a) < (b) ? (a) : (b))

void invert_byte_order ( int len, unsigned char *data );
void dump_buffer (FILE *fp, char *heading,
		  const unsigned char *buffer, int bufsize);

void *xmalloc(size_t size);
void *xrealloc(void *buf, size_t size);
void _xfree(void *buf);
#define xfree(ptr) do { _xfree(ptr); ptr = NULL; } while(0)
char *xstrndup(const char *s, int len);
char *xstrdup(const char *s);

#ifndef NO_DESTROY
/* Create soem invalid symbols to detect the use of the original functions */
#define malloc foo-malloc
#define realloc foo-realloc
#define free foo-free
#define strdup foo-strdup
#define strndup foo-strndup
#endif

#define _UTIL_H
#endif

/* Emacs local variables

Local variables:
eval: (set-c-style "BSD")
end:

*/
