1 /* xmemdup.c -- Duplicate a memory buffer, using xcalloc.
2 This trivial function is in the public domain.
3 Jeff Garzik, September 1999. */
7 @deftypefn Replacement void* xmemdup (void *@var{input}, size_t @var{copy_size}, size_t @var{alloc_size})
9 Duplicates a region of memory without fail. First, @var{alloc_size} bytes
10 are allocated, then @var{copy_size} bytes from @var{input} are copied into
11 it, and the new memory is returned. If fewer bytes are copied than were
12 allocated, the remaining memory is zeroed.
22 #include "libiberty.h"
24 #include <sys/types.h> /* For size_t. */
30 xmemdup (input
, copy_size
, alloc_size
)
35 PTR output
= xcalloc (1, alloc_size
);
36 memcpy (output
, input
, copy_size
);
This page took 0.029429 seconds and 4 git commands to generate.