aboutsummaryrefslogtreecommitdiffstats
path: root/support/xalloc.h
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2021-08-29 18:53:55 +0300
committerArnold D. Robbins <arnold@skeeve.com>2021-08-29 18:53:55 +0300
commit0e1761697d8ed24b07cf23035f5dd01d09056e3a (patch)
tree0bfa58691f81e87f3098d736bc0409c4dd5fc40c /support/xalloc.h
parent6696453c1a733436cbb9ca41c7c75eeb4e0b428a (diff)
downloadegawk-0e1761697d8ed24b07cf23035f5dd01d09056e3a.tar.gz
egawk-0e1761697d8ed24b07cf23035f5dd01d09056e3a.tar.bz2
egawk-0e1761697d8ed24b07cf23035f5dd01d09056e3a.zip
Sync support with GNULIB updates.
Diffstat (limited to 'support/xalloc.h')
-rw-r--r--support/xalloc.h11
1 files changed, 11 insertions, 0 deletions
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_ */