MoarVM
MoarVM copied to clipboard
Building strncpy if not provided
In MSVC, there is no strncpy, which makes it hard to build telemeh:
telemeh.obj : error LNK2001: unresolved external symbol strndup
moar.dll : fatal error LNK1120: 1 unresolved externals
A simple solution could be adding a definition of strncpy, like this:
char *strndup(char const *s, size_t n)
{
size_t len = strnlen(s, n);
char *new = malloc(len + 1);
if (!new)
return NULL;
new[len] = '\0';
return memcpy(new, s, len);
}