diff libiberty/xmemdup.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children
line wrap: on
line diff
--- a/libiberty/xmemdup.c	Sun Aug 21 07:07:55 2011 +0900
+++ b/libiberty/xmemdup.c	Fri Oct 27 22:46:09 2017 +0900
@@ -1,4 +1,4 @@
-/* xmemdup.c -- Duplicate a memory buffer, using xcalloc.
+/* xmemdup.c -- Duplicate a memory buffer, using xmalloc.
    This trivial function is in the public domain.
    Jeff Garzik, September 1999.  */
 
@@ -34,6 +34,8 @@
 PTR
 xmemdup (const PTR input, size_t copy_size, size_t alloc_size)
 {
-  PTR output = xcalloc (1, alloc_size);
+  PTR output = xmalloc (alloc_size);
+  if (alloc_size > copy_size)
+    memset ((char *) output + copy_size, 0, alloc_size - copy_size);
   return (PTR) memcpy (output, input, copy_size);
 }