[talloc] Provide a copy of strnlen on OSX

The implementation is taken from a blogspot and I don't think
it is copyrightable...
This commit is contained in:
Holger Hans Peter Freyther 2009-11-21 19:41:06 +01:00
parent 7466351026
commit a8816dd9c7
1 changed files with 9 additions and 0 deletions

View File

@ -105,6 +105,15 @@
#endif
#endif
#ifdef __APPLE__
/* taken from http://insanecoding.blogspot.com/2007/03/methods-for-safe-string-handling.html */
size_t strnlen(const char *s, size_t n)
{
const char *p = (const char *)memchr(s, 0, n);
return(p ? p-s : n);
}
#endif
/* this null_context is only used if talloc_enable_leak_report() or
talloc_enable_leak_report_full() is called, otherwise it remains
NULL