From 0e1761697d8ed24b07cf23035f5dd01d09056e3a Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Sun, 29 Aug 2021 18:53:55 +0300 Subject: Sync support with GNULIB updates. --- support/xalloc.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'support/xalloc.h') diff --git a/support/xalloc.h b/support/xalloc.h index bb893294..38a14873 100644 --- a/support/xalloc.h +++ b/support/xalloc.h @@ -436,5 +436,16 @@ xpalloc (void *pa, idx_t *nitems, idx_t nitems_incr_min, return pa; } +/* Clone an object P of size S, with error checking. Append + a terminating NUL byte. */ + +char * +ximemdup0 (void const *p, idx_t s) +{ + char *result = malloc(s + 1); + result[s] = 0; + return memcpy (result, p, s); +} + #endif /* !XALLOC_H_ */ -- cgit v1.2.3