OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [libiberty/] [xmemdup.c] - Blame information for rev 832

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
/* xmemdup.c -- Duplicate a memory buffer, using xcalloc.
2
   This trivial function is in the public domain.
3
   Jeff Garzik, September 1999.  */
4
 
5
/*
6
 
7
@deftypefn Replacement void* xmemdup (void *@var{input}, size_t @var{copy_size}, size_t @var{alloc_size})
8
 
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.
13
 
14
@end deftypefn
15
 
16
*/
17
 
18
#ifdef HAVE_CONFIG_H
19
#include "config.h"
20
#endif
21
#include "ansidecl.h"
22
#include "libiberty.h"
23
 
24
#include <sys/types.h> /* For size_t. */
25
#ifdef HAVE_STRING_H
26
#include <string.h>
27
#else
28
# ifdef HAVE_STRINGS_H
29
#  include <strings.h>
30
# endif
31
#endif
32
 
33
PTR
34
xmemdup (const PTR input, size_t copy_size, size_t alloc_size)
35
{
36
  PTR output = xcalloc (1, alloc_size);
37
  return (PTR) memcpy (output, input, copy_size);
38
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.