comparison libiberty/xmemdup.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* xmemdup.c -- Duplicate a memory buffer, using xcalloc. 1 /* xmemdup.c -- Duplicate a memory buffer, using xmalloc.
2 This trivial function is in the public domain. 2 This trivial function is in the public domain.
3 Jeff Garzik, September 1999. */ 3 Jeff Garzik, September 1999. */
4 4
5 /* 5 /*
6 6
32 #endif 32 #endif
33 33
34 PTR 34 PTR
35 xmemdup (const PTR input, size_t copy_size, size_t alloc_size) 35 xmemdup (const PTR input, size_t copy_size, size_t alloc_size)
36 { 36 {
37 PTR output = xcalloc (1, alloc_size); 37 PTR output = xmalloc (alloc_size);
38 if (alloc_size > copy_size)
39 memset ((char *) output + copy_size, 0, alloc_size - copy_size);
38 return (PTR) memcpy (output, input, copy_size); 40 return (PTR) memcpy (output, input, copy_size);
39 } 41 }