]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Add two more functions, for gnulib compatibility.
authorBruno Haible <bruno@clisp.org>
Mon, 6 Nov 2006 20:34:54 +0000 (20:34 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:14:19 +0000 (12:14 +0200)
gnulib-local/ChangeLog
gnulib-local/lib/xalloc.h
gnulib-local/lib/xstrdup.c

index a9237a371fb0f7a8a204bc0737569aec6c53eb0d..91b82d526bb4803430f0bbce0dd2c561c6a559d8 100644 (file)
@@ -1,3 +1,9 @@
+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.
index ceb1eb926cac8c3ce4c9b687a3aa4e43f73f1da6..1168a546c1234ae43634e665c1f207357d6bde81 100644 (file)
@@ -111,9 +111,17 @@ xnboundedmalloc (size_t n, size_t bound, size_t s)
 #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);
 
index cb3c53be68239d4bcc566448da0092b4a39eecf7..842e99a2989df88e318f0dedffe6187f485a06c4 100644 (file)
 
 #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 *