X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flib%2Fstring.c;h=89fa1f05c01f130bce10948d493a10cac6d29063;hb=415941c1e0a6fc5ce263d8355fde980239c0f844;hp=bec4444670b025768485cb143edb0329de3cb60c;hpb=f2f8875638593bd5365cfd6a5ba7c9578e52322f;p=pintos-anon diff --git a/src/lib/string.c b/src/lib/string.c index bec4444..89fa1f0 100644 --- a/src/lib/string.c +++ b/src/lib/string.c @@ -1,4 +1,8 @@ #include + +#ifdef KERNEL +#define NDEBUG +#endif #include /* Copies SIZE bytes from SRC to DST, which must not overlap. @@ -212,7 +216,9 @@ strstr (const char *haystack, const char *needle) single string. strtok_r() modifies the string S, changing delimiters to null - bytes. Thus, S must be a modifiable string. + bytes. Thus, S must be a modifiable string. String literals, + in particular, are *not* modifiable in C, even though for + backward compatibility they are not `const'. Example usage: @@ -333,7 +339,7 @@ strlcpy (char *dst, const char *src, size_t size) { size_t dst_len = size - 1; if (src_len < dst_len) - src_len = dst_len; + dst_len = src_len; memcpy (dst, src, dst_len); dst[dst_len] = '\0'; }