subsurface/core/strndup.h
Berthold Stoeger 924b23ed56 core: convert git-access.c to C++
Had to make sha.h compatible with C++.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-10 11:01:42 +13:00

22 lines
362 B
C

// SPDX-License-Identifier: GPL-2.0
#ifndef STRNDUP_H
#define STRNDUP_H
#if __WIN32__
static char *strndup (const char *s, size_t n)
{
char *cpy;
size_t len = strlen(s);
if (n < len)
len = n;
if ((cpy = (char *)malloc(len + 1)) !=
NULL) {
cpy[len] =
'\0';
memcpy(cpy,
s,
len);
}
return cpy;
}
#endif
#endif /* STRNDUP_H */