From: Bruno Haible Date: Mon, 27 Nov 2006 12:40:36 +0000 (+0000) Subject: Add a template for xmemdup, so that quotearg.c compiles in C++ mode. X-Git-Tag: v0.17~634 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=076307925fed63a574eb7fec2359a89a85e109d1;p=thirdparty%2Fgettext.git Add a template for xmemdup, so that quotearg.c compiles in C++ mode. --- diff --git a/gnulib-local/ChangeLog b/gnulib-local/ChangeLog index d16273b1f..3cfbae7f1 100644 --- a/gnulib-local/ChangeLog +++ b/gnulib-local/ChangeLog @@ -1,3 +1,8 @@ +2006-11-26 Bruno Haible + + * lib/xalloc.h (xmemdup): Add a typesafe C++ template variant. + Based on a patch from Paul Eggert in gnulib. + 2006-11-26 Bruno Haible Optimize IS_INSTANCE. diff --git a/gnulib-local/lib/xalloc.h b/gnulib-local/lib/xalloc.h index 1168a546c..e92d9a340 100644 --- a/gnulib-local/lib/xalloc.h +++ b/gnulib-local/lib/xalloc.h @@ -52,7 +52,7 @@ extern void *xrealloc (void *ptr, size_t size); template 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 + 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);