mingw/win32 lacks strndup.

This commit is contained in:
ksherlock 2019-02-18 11:24:08 -05:00 committed by GitHub
parent 8584df91f5
commit b9e36df2bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -49,6 +49,21 @@ 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>
static char *get_resource_path(const char *leaf) {