+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.
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
/* 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);