win32 missing strndup

This commit is contained in:
Kelvin Sherlock 2019-02-19 19:48:39 -05:00
parent b9e36df2bb
commit 58351d1db7
2 changed files with 16 additions and 13 deletions

View File

@ -49,20 +49,7 @@ extern word32 debug_apply_template(word32 address, const char *name);
extern void debug_load_tools(const char *path, unsigned vector);
extern const char *debug_tool_name(unsigned, unsigned vector);
#ifdef WIN32
char *strndup(const char *s, size_t maxlen) {
char *cp;
size_t l = strlen(s);
if (l > maxlen) l = maxlen;
cp = malloc(l + 1);
if (cp) {
memcpy(cp, s, l);
cp[l] = 0;
}
return cp;
}
#endif
#if defined(__APPLE__)
#include <mach-o/dyld.h>

View File

@ -10,6 +10,22 @@
#include "defc.h"
#ifdef WIN32
char *strndup(const char *s, size_t maxlen) {
char *cp;
size_t l = strlen(s);
if (l > maxlen) l = maxlen;
cp = malloc(l + 1);
if (cp) {
memcpy(cp, s, l);
cp[l] = 0;
}
return cp;
}
#endif
/*!re2c
re2c:define:YYCTYPE = char;
re2c:define:YYCURSOR = cp;