]> git.ipfire.org Git - thirdparty/gcc.git/blame - libiberty/xmemdup.c
* xmemdup.c: New xmemdup function.
[thirdparty/gcc.git] / libiberty / xmemdup.c
CommitLineData
7570bccb 1/* xmemdup.c -- Duplicate a memory buffer, using xcalloc.
2 This trivial function is in the public domain.
3 Jeff Garzik, September 1999. */
4
5#ifdef HAVE_CONFIG_H
6#include "config.h"
7#endif
8#include "ansidecl.h"
9#include "libiberty.h"
10
11PTR
12xmemdup (input, copy_size, alloc_size)
13 const PTR input;
14 size_t copy_size;
15 size_t alloc_size;
16{
17 PTR output = xcalloc (1, alloc_size);
18 memcpy (output, input, copy_size);
19 return output;
20}