Mercurial > hg-old > index.cgi
diff lwlib/lw_string.c @ 329:c15cca3ae6a2
Created first pass of input layer
author | lost |
---|---|
date | Sun, 28 Feb 2010 05:01:31 +0000 |
parents | 2eb058346cad |
children |
line wrap: on
line diff
--- a/lwlib/lw_string.c Sat Feb 13 06:08:26 2010 +0000 +++ b/lwlib/lw_string.c Sun Feb 28 05:01:31 2010 +0000 @@ -40,6 +40,21 @@ return r; } +char *lw_strndup(const char *s, int len) +{ + char *r; + int sl; + + sl = strlen(s); + if (sl > len) + sl = len; + + r = lw_alloc(sl + 1); + memmove(r, s, sl); + r[sl] = '\0'; + return r; +} + char *lw_token(const char *s, int sep, const char **ap) { const char *p;