diff options
author | Oleg Safiullin <form@cvs.openbsd.org> | 2000-04-24 03:33:28 +0000 |
---|---|---|
committer | Oleg Safiullin <form@cvs.openbsd.org> | 2000-04-24 03:33:28 +0000 |
commit | 48b49e3dbecf303d0aa748ddd58e2b05c7062ce5 (patch) | |
tree | 49386f86a690e410bc8543edaf0a5ac8215254a3 /gnu/usr.bin/ld/etc.c | |
parent | 4652f5890765d50db31ba39442dd315754d49698 (diff) |
Add xstrdup() - like strdup but get fatal error if memory is exhausted.
Avoid duplicates in search path.
ok espie@
Diffstat (limited to 'gnu/usr.bin/ld/etc.c')
-rw-r--r-- | gnu/usr.bin/ld/etc.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/gnu/usr.bin/ld/etc.c b/gnu/usr.bin/ld/etc.c index d3716f03ece..1b6aec578c4 100644 --- a/gnu/usr.bin/ld/etc.c +++ b/gnu/usr.bin/ld/etc.c @@ -1,4 +1,4 @@ -/* * $OpenBSD: etc.c,v 1.2 1998/03/26 19:46:18 niklas Exp $*/ +/* * $OpenBSD: etc.c,v 1.3 2000/04/24 03:33:27 form Exp $*/ /* */ @@ -7,6 +7,21 @@ #include <string.h> /* + * Like strdup but get fatal error if memory is exhausted. + */ +char * +xstrdup(s) + char *s; +{ + char *result = strdup(s); + + if (!result) + errx(1, "virtual memory exhausted"); + + return result; +} + +/* * Like malloc but get fatal error if memory is exhausted. */ void * |