Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Modules/i386/klibc/strlcpy.c

1/*
2 * strlcpy.c
3 */
4
5#include <string.h>
6#include <klibc/compiler.h>
7
8size_t strlcpy(char *dst, const char *src, size_t size)
9{
10size_t bytes = 0;
11char *q = dst;
12const char *p = src;
13char ch;
14
15while ((ch = *p++)) {
16if (bytes + 1 < size)
17*q++ = ch;
18
19bytes++;
20}
21
22/* If size == 0 there is no space for a final null... */
23if (size)
24*q = '\0';
25
26return bytes;
27}
28

Archive Download this file

Revision: 1751