]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Add a template for xmemdup, so that quotearg.c compiles in C++ mode.
authorBruno Haible <bruno@clisp.org>
Mon, 27 Nov 2006 12:40:36 +0000 (12:40 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:14:24 +0000 (12:14 +0200)
gnulib-local/ChangeLog
gnulib-local/lib/xalloc.h

index d16273b1f283d883c3fe204f124a19c1e73f39a2..3cfbae7f1f756d3d49b443c68267a0ec1d7a54b2 100644 (file)
@@ -1,3 +1,8 @@
+2006-11-26  Bruno Haible  <bruno@clisp.org>
+
+       * lib/xalloc.h (xmemdup): Add a typesafe C++ template variant.
+       Based on a patch from Paul Eggert in gnulib.
+
 2006-11-26  Bruno Haible  <bruno@clisp.org>
 
        Optimize IS_INSTANCE.
index 1168a546c1234ae43634e665c1f207357d6bde81..e92d9a3405156b2020bd2941dda1c81b25ae9afe 100644 (file)
@@ -52,7 +52,7 @@ extern void *xrealloc (void *ptr, size_t size);
 template <typename T>
   inline T * xrealloc (T * ptr, size_t size)
   {
-    return (T *) xrealloc((void *) ptr, size);
+    return (T *) xrealloc ((void *) ptr, size);
   }
 extern "C" {
 #endif
@@ -121,6 +121,15 @@ xnboundedmalloc (size_t n, size_t bound, size_t s)
 
 /* Return a newly allocated copy of the N bytes of memory starting at P.  */
 extern void *xmemdup (const void *p, size_t n);
+#ifdef __cplusplus
+}
+template <typename T>
+  inline T * xmemdup (const T * p, size_t n)
+  {
+    return (T *) xmemdup ((const void *) p, n);
+  }
+extern "C" {
+#endif
 
 /* Return a newly allocated copy of STRING.  */
 extern char *xstrdup (const char *string);