+2006-11-06 Bruno Haible <bruno@clisp.org>
+
+ * lib/xalloc.h (xcharalloc): New macro.
+ (xmemdup): New declaration.
+ * lib/xstrdup.c (xmemdup): New function.
+
2006-11-03 Bruno Haible <bruno@clisp.org>
* lib/xalloc.h (XMALLOC, XNMALLOC, XZALLOC, XCALLOC): New macros.
#define XCALLOC(N,T) \
((T *) xcalloc (N, sizeof (T)))
+/* Return a pointer to a new buffer of N bytes. This is like xmalloc,
+ except it returns char *. */
+#define xcharalloc(N) \
+ XNMALLOC (N, char)
+
/* Defined in xstrdup.c. */
+/* Return a newly allocated copy of the N bytes of memory starting at P. */
+extern void *xmemdup (const void *p, size_t n);
+
/* Return a newly allocated copy of STRING. */
extern char *xstrdup (const char *string);
#include <string.h>
+/* Return a newly allocated copy of the N bytes of memory starting at P. */
+
+void *
+xmemdup (const void *p, size_t n)
+{
+ void *q = xmalloc (n);
+ memcpy (q, p, n);
+ return q;
+}
+
/* Return a newly allocated copy of STRING. */
char *