aboutsummaryrefslogtreecommitdiff
path: root/lib/compat.c
blob: 5fd2cc4756b7523aab34842790af9608532512cc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "config.h"

#ifndef HAVE_STRSEP
#include <string.h>
// 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 <stdlib.h>
void *reallocarray (void *__ptr, size_t __nmemb, size_t __size) {
    return realloc(__ptr, __nmemb * __size);
}
#endif