aboutsummaryrefslogtreecommitdiffstats
path: root/xalloc.h
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2012-11-25 21:54:48 +0200
committerArnold D. Robbins <arnold@skeeve.com>2012-11-25 21:54:48 +0200
commit9a9ff61bbd952c1263b55f82a269da5b09289a6b (patch)
tree4bc31b31d0bec6d27f77e55f1a88f50534fa6ed4 /xalloc.h
parentdbabe5a569ad82a9faeb2f121e387ec6399f9dcb (diff)
parent7af1da783175273a26609911c3a95975ed0f5c13 (diff)
downloadegawk-9a9ff61bbd952c1263b55f82a269da5b09289a6b.tar.gz
egawk-9a9ff61bbd952c1263b55f82a269da5b09289a6b.tar.bz2
egawk-9a9ff61bbd952c1263b55f82a269da5b09289a6b.zip
Merge branch 'master' into array-iface
Diffstat (limited to 'xalloc.h')
-rw-r--r--xalloc.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/xalloc.h b/xalloc.h
index 5810fc55..eb0ef1a0 100644
--- a/xalloc.h
+++ b/xalloc.h
@@ -169,6 +169,16 @@ xalloc_die (void)
r_fatal(_("xalloc: malloc failed: %s"), strerror(errno));
}
+
+/* Clone an object P of size S, with error checking. There's no need
+ for xnmemdup (P, N, S), since xmemdup (P, N * S) works without any
+ need for an arithmetic overflow check. */
+
+void *
+xmemdup (void const *p, size_t s)
+{
+ return memcpy (xmalloc (s), p, s);
+}
#endif
/* Change the size of an allocated block of memory P to an array of N