From 825a6218314c1afcf7aa63267ca070a37e80bf4b Mon Sep 17 00:00:00 2001 From: Kate F Date: Fri, 31 May 2024 08:09:21 -0700 Subject: [PATCH] No need to depend on POSIX here. --- src/adt/xalloc.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/adt/xalloc.c b/src/adt/xalloc.c index bdce10a49..91ee82431 100644 --- a/src/adt/xalloc.c +++ b/src/adt/xalloc.c @@ -4,8 +4,6 @@ * See LICENCE for the full copyright terms. */ -#define _POSIX_C_SOURCE 200809L - #include #include #include @@ -29,13 +27,14 @@ xstrdup(const char *s) char * xstrndup(const char *s, size_t n) { - char *new = strndup(s, n); + char *new; + + new = malloc(n); if (new == NULL) { - perror("strndup"); - abort(); + return NULL; } - return new; + return memcpy(new, s, n); } void *