diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2009-11-21 19:41:06 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2009-11-22 05:28:14 +0100 |
commit | a8816dd9c76627ea2f99f7405e4f44b008f1401a (patch) | |
tree | d22bc1bda5986e607132b62fb6540e69ae818d39 /openbsc/src/talloc.c | |
parent | 7466351026f09364aa9b92ae921e564519bb115e (diff) |
[talloc] Provide a copy of strnlen on OSX
The implementation is taken from a blogspot and I don't think
it is copyrightable...
Diffstat (limited to 'openbsc/src/talloc.c')
-rw-r--r-- | openbsc/src/talloc.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/openbsc/src/talloc.c b/openbsc/src/talloc.c index bd5e1b0e0..d8213238e 100644 --- a/openbsc/src/talloc.c +++ b/openbsc/src/talloc.c @@ -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 |