mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 08:43:19 -04:00
Implement xstrdup() using strlen()/xmalloc()/memcpy() already
presented in rtld, instead of pulling in libc strdup(). Submitted by: bde MFC after: 2 weeks
This commit is contained in:
parent
3b5683fce6
commit
f7b343037f
1 changed files with 8 additions and 7 deletions
|
|
@ -57,12 +57,13 @@ xmalloc(size_t size)
|
|||
}
|
||||
|
||||
char *
|
||||
xstrdup(const char *s)
|
||||
xstrdup(const char *str)
|
||||
{
|
||||
char *p = strdup(s);
|
||||
if (p == NULL) {
|
||||
rtld_fdputstr(STDERR_FILENO, "Out of memory\n");
|
||||
_exit(1);
|
||||
}
|
||||
return p;
|
||||
char *copy;
|
||||
size_t len;
|
||||
|
||||
len = strlen(str) + 1;
|
||||
copy = xmalloc(len);
|
||||
memcpy(copy, str, len);
|
||||
return (copy);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue