Initial revision
[binutils.git] / libiberty / xmemdup.c
blobf780041aa1330837d66fa1004f5619ca46c60afa
1 /* xmemdup.c -- Duplicate a memory buffer, using xcalloc.
2 This trivial function is in the public domain.
3 Jeff Garzik, September 1999. */
5 #ifdef HAVE_CONFIG_H
6 #include "config.h"
7 #endif
8 #include "ansidecl.h"
9 #include "libiberty.h"
11 #include <sys/types.h> /* For size_t. */
13 PTR
14 xmemdup (input, copy_size, alloc_size)
15 const PTR input;
16 size_t copy_size;
17 size_t alloc_size;
19 PTR output = xcalloc (1, alloc_size);
20 memcpy (output, input, copy_size);
21 return output;