Chameleon

Chameleon Svn Source Tree

Root/branches/xZenu/src/modules/klibc/strlcpy.c

Source at commit 1292 created 12 years 8 months ago.
By meklort, Add additional functions to klibc. Remove duplicates from libsa
1/*
2 * strlcpy.c
3 */
4
5#include <string.h>
6
7size_t strlcpy(char *dst, const char *src, size_t size)
8{
9size_t bytes = 0;
10char *q = dst;
11const char *p = src;
12char ch;
13
14while ((ch = *p++)) {
15if (bytes + 1 < size)
16*q++ = ch;
17
18bytes++;
19}
20
21/* If size == 0 there is no space for a final null... */
22if (size)
23*q = '\0';
24
25return bytes;
26}
27

Archive Download this file

Revision: 1292