diff options
author | Bruno Haible <bruno@clisp.org> | 2006-11-27 12:40:36 +0000 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2009-06-23 12:14:24 +0200 |
commit | 076307925fed63a574eb7fec2359a89a85e109d1 (patch) | |
tree | 93c42ff4cae4bfef7a4bfef39c9abdc537dadf88 /gnulib-local | |
parent | 1b8f928378053cd0d983f062f753c4972fbcff15 (diff) | |
download | external_gettext-076307925fed63a574eb7fec2359a89a85e109d1.zip external_gettext-076307925fed63a574eb7fec2359a89a85e109d1.tar.gz external_gettext-076307925fed63a574eb7fec2359a89a85e109d1.tar.bz2 |
Add a template for xmemdup, so that quotearg.c compiles in C++ mode.
Diffstat (limited to 'gnulib-local')
-rw-r--r-- | gnulib-local/ChangeLog | 5 | ||||
-rw-r--r-- | gnulib-local/lib/xalloc.h | 11 |
2 files changed, 15 insertions, 1 deletions
diff --git a/gnulib-local/ChangeLog b/gnulib-local/ChangeLog index d16273b..3cfbae7 100644 --- a/gnulib-local/ChangeLog +++ b/gnulib-local/ChangeLog @@ -1,5 +1,10 @@ 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. * build-aux/moopp: Emit also a classname_SUPERCLASSES_LENGTH macro. * lib/moo.h (IS_INSTANCE): Use the value of this macro, known at diff --git a/gnulib-local/lib/xalloc.h b/gnulib-local/lib/xalloc.h index 1168a54..e92d9a3 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 <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); |