Root/
Source at commit 320 created 12 years 10 months ago. By ifabio, More updated stuff from Azimutz GraphicsEnabler sub-Branch http://forge.voodooprojects.org/p/chameleon/source/tree/HEAD/branches/azimutz/trunkGraphicsEnablerModules. | |
---|---|
1 | /*␊ |
2 | * strnlen()␊ |
3 | */␊ |
4 | ␊ |
5 | #include <string.h>␊ |
6 | ␊ |
7 | size_t strnlen(const char *s, size_t maxlen)␊ |
8 | {␊ |
9 | ␉const char *ss = s;␊ |
10 | ␊ |
11 | ␉/* Important: the maxlen test must precede the reference through ss;␊ |
12 | ␉ since the byte beyond the maximum may segfault */␊ |
13 | ␉while ((maxlen > 0) && *ss) {␊ |
14 | ␉␉ss++;␊ |
15 | ␉␉maxlen--;␊ |
16 | ␉}␊ |
17 | ␉return ss - s;␊ |
18 | }␊ |
19 |