diff options
author | Andrew C. Morrow <andrew.c.morrow@gmail.com> | 2010-07-27 13:46:41 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2010-07-27 18:15:48 -0400 |
commit | 6239b1629aee6563c1d110d709ee1ce1f2c49ca8 (patch) | |
tree | e7203999b283dcf776fb58828280ab074abdc94d /bson/util/misc.h | |
parent | 2bc93939b5e4834946efe3a8c0a7bd380b34d2b9 (diff) | |
download | mongo-6239b1629aee6563c1d110d709ee1ce1f2c49ca8.tar.gz |
SERVER-1498: qualify custom strnlen in bsoninlines, move impl
- strnlen was ambiguous in bsoninlines.h without goodies.h header
- goodies.h header includes lots of other stuff, so moved custom
strnlen to bson/util/misc.h.
- update bsoninlines.h to use namespace qualified name
Diffstat (limited to 'bson/util/misc.h')
-rw-r--r-- | bson/util/misc.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/bson/util/misc.h b/bson/util/misc.h index de5902528c4..cad9a284458 100644 --- a/bson/util/misc.h +++ b/bson/util/misc.h @@ -82,5 +82,13 @@ namespace mongo { return buf; } }; - + + // Like strlen, but only scans up to n bytes. + // Returns -1 if no '0' found. + inline int strnlen( const char *s, int n ) { + for( int i = 0; i < n; ++i ) + if ( !s[ i ] ) + return i; + return -1; + } } |