Remove the need for the less than standard strnlen()/strndup().

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7326 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Soren Jorvang
2011-03-11 00:37:37 +00:00
parent 1f42629112
commit 4f69672b2b
4 changed files with 6 additions and 34 deletions

View File

@ -36,27 +36,3 @@ const char *GetLastErrorMsg()
#endif
return errStr;
}
#if !defined(__linux__) && !defined(_WIN32)
// strlen with cropping after size n
static size_t strnlen(const char *s, size_t n)
{
const char *p = (const char *)memchr(s, 0, n);
return p ? (size_t)(p - s) : n;
}
#endif
#if defined(_WIN32) || !(__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
// strdup with cropping after size n
char* strndup(char const *s, size_t n)
{
size_t len = strnlen(s, n);
char *dup = (char *)malloc(len + 1);
if (dup == NULL)
return NULL;
dup[len] = '\0';
return (char *)memcpy(dup, s, len);
}
#endif