mirror of
https://github.com/darlinghq/darling-gdb.git
synced 2024-12-07 12:06:44 +00:00
5c82d20a26
if HAVE_STRING_H. * pexecute.c, xexit.c: Include stdlib.h if HAVE_STDLIB_H. * objalloc.c: Include config.h. Include stdlib.h and don't declare malloc or free if HAVE_STDLIB_H. * strerror.c, strsignal.c: Include stdlib.h if HAVE_STDLIB_H, else declare malloc without prototype. Include string.h if HAVE_STRING_H, else declare memset without prototype. Don't include stddef.h. * sort.c: Bring over from GCC.
26 lines
530 B
C
26 lines
530 B
C
/* xmemdup.c -- Duplicate a memory buffer, using xcalloc.
|
|
This trivial function is in the public domain.
|
|
Jeff Garzik, September 1999. */
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
#include "ansidecl.h"
|
|
#include "libiberty.h"
|
|
|
|
#include <sys/types.h> /* For size_t. */
|
|
#ifdef HAVE_STRING_H
|
|
#include <string.h>
|
|
#endif
|
|
|
|
PTR
|
|
xmemdup (input, copy_size, alloc_size)
|
|
const PTR input;
|
|
size_t copy_size;
|
|
size_t alloc_size;
|
|
{
|
|
PTR output = xcalloc (1, alloc_size);
|
|
memcpy (output, input, copy_size);
|
|
return output;
|
|
}
|