From ccaeb7092b5ad40b1b3833c987ba3ec4d47f0bb8 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 18 Mar 2020 22:25:27 -0400 Subject: Refactor project: build/install libspm[_static.a].so to make unit testing possible --- lib/compat.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 lib/compat.c (limited to 'lib/compat.c') diff --git a/lib/compat.c b/lib/compat.c new file mode 100644 index 0000000..5fd2cc4 --- /dev/null +++ b/lib/compat.c @@ -0,0 +1,23 @@ +#include "config.h" + +#ifndef HAVE_STRSEP +#include +// credit: Dan Cross via https://unixpapa.com/incnote/string.html +char *strsep(char **sp, char *sep) +{ + char *p, *s; + if (sp == NULL || *sp == NULL || **sp == '\0') return(NULL); + s = *sp; + p = s + strcspn(s, sep); + if (*p != '\0') *p++ = '\0'; + *sp = p; + return(s); +} +#endif + +#ifndef HAVE_REALLOCARRAY +#include +void *reallocarray (void *__ptr, size_t __nmemb, size_t __size) { + return realloc(__ptr, __nmemb * __size); +} +#endif -- cgit