mirror of
https://github.com/digarok/gsplus.git
synced 2024-05-28 13:41:31 +00:00
win32 missing strndup
This commit is contained in:
parent
b9e36df2bb
commit
58351d1db7
|
@ -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>
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user