URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Go to most recent revision |
Only display areas with differences |
Details |
Blame |
View Log
Rev 816 |
Rev 826 |
/* xstrdup.c -- Duplicate a string in memory, using xmalloc.
|
/* xstrdup.c -- Duplicate a string in memory, using xmalloc.
|
This trivial function is in the public domain.
|
This trivial function is in the public domain.
|
Ian Lance Taylor, Cygnus Support, December 1995. */
|
Ian Lance Taylor, Cygnus Support, December 1995. */
|
|
|
/*
|
/*
|
|
|
@deftypefn Replacement char* xstrdup (const char *@var{s})
|
@deftypefn Replacement char* xstrdup (const char *@var{s})
|
|
|
Duplicates a character string without fail, using @code{xmalloc} to
|
Duplicates a character string without fail, using @code{xmalloc} to
|
obtain memory.
|
obtain memory.
|
|
|
@end deftypefn
|
@end deftypefn
|
|
|
*/
|
*/
|
|
|
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
#include "config.h"
|
#include "config.h"
|
#endif
|
#endif
|
#include <sys/types.h>
|
#include <sys/types.h>
|
#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
|
#include "ansidecl.h"
|
#include "ansidecl.h"
|
#include "libiberty.h"
|
#include "libiberty.h"
|
|
|
char *
|
char *
|
xstrdup (const char *s)
|
xstrdup (const char *s)
|
{
|
{
|
register size_t len = strlen (s) + 1;
|
register size_t len = strlen (s) + 1;
|
register char *ret = XNEWVEC (char, len);
|
register char *ret = XNEWVEC (char, len);
|
return (char *) memcpy (ret, s, len);
|
return (char *) memcpy (ret, s, len);
|
}
|
}
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.