add NEED_STRDUP for C89 support

C89 does not define strdup(), so provide an implementation for
the systems that doesn't implement it. Enable it by adding
"CPPFLAG += -DNEED_STRDUP" to config.mak.
This commit is contained in:
Erik Faye-Lund 2010-06-19 15:21:32 +02:00
parent ab243a6c1a
commit ca123707b3

View File

@ -71,4 +71,15 @@ static inline int xrecv(SOCKET s, void *buf, size_t len, int flags)
return recv(s, (char *)buf, len, flags) != (int)len;
}
#ifdef NEED_STRDUP
static inline char *rocket_strdup(const char *str)
{
char *ret = malloc(strlen(str) + 1);
if (ret)
strcpy(ret, str);
return ret;
}
#define strdup rocket_strdup
#endif
#endif /* SYNC_BASE_H */