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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [libiberty/] [xmemdup.c] - Diff between revs 816 and 834

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 816 Rev 834
/* xmemdup.c -- Duplicate a memory buffer, using xcalloc.
/* xmemdup.c -- Duplicate a memory buffer, using xcalloc.
   This trivial function is in the public domain.
   This trivial function is in the public domain.
   Jeff Garzik, September 1999.  */
   Jeff Garzik, September 1999.  */
 
 
/*
/*
 
 
@deftypefn Replacement void* xmemdup (void *@var{input}, size_t @var{copy_size}, size_t @var{alloc_size})
@deftypefn Replacement void* xmemdup (void *@var{input}, size_t @var{copy_size}, size_t @var{alloc_size})
 
 
Duplicates a region of memory without fail.  First, @var{alloc_size} bytes
Duplicates a region of memory without fail.  First, @var{alloc_size} bytes
are allocated, then @var{copy_size} bytes from @var{input} are copied into
are allocated, then @var{copy_size} bytes from @var{input} are copied into
it, and the new memory is returned.  If fewer bytes are copied than were
it, and the new memory is returned.  If fewer bytes are copied than were
allocated, the remaining memory is zeroed.
allocated, the remaining memory is zeroed.
 
 
@end deftypefn
@end deftypefn
 
 
*/
*/
 
 
#ifdef HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#include "config.h"
#endif
#endif
#include "ansidecl.h"
#include "ansidecl.h"
#include "libiberty.h"
#include "libiberty.h"
 
 
#include <sys/types.h> /* For size_t. */
#include <sys/types.h> /* For size_t. */
#ifdef HAVE_STRING_H
#ifdef HAVE_STRING_H
#include <string.h>
#include <string.h>
#else
#else
# ifdef HAVE_STRINGS_H
# ifdef HAVE_STRINGS_H
#  include <strings.h>
#  include <strings.h>
# endif
# endif
#endif
#endif
 
 
PTR
PTR
xmemdup (const PTR input, size_t copy_size, size_t alloc_size)
xmemdup (const PTR input, size_t copy_size, size_t alloc_size)
{
{
  PTR output = xcalloc (1, alloc_size);
  PTR output = xcalloc (1, alloc_size);
  return (PTR) memcpy (output, input, copy_size);
  return (PTR) memcpy (output, input, copy_size);
}
}
 
 

powered by: WebSVN 2.1.0

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