sweep through entire page table to free up intermediate tables
[lunaix-os.git] / lunaix-os / libs / klibc / string / strcpy.c
1 #include <klibc/string.h>
2 #include <lunaix/compiler.h>
3
4 char* _weak
5 strcpy(char* dest, const char* src)
6 {
7     char c;
8     unsigned int i = 0;
9     while ((c = src[i])) {
10         dest[i] = c;
11         i++;
12     }
13     dest[i++] = '\0';
14     return &dest[i];
15 }
16
17 /**
18  * @brief strcpy with constrain on numbers of character.
19  *        this version is smarter than stdc, it will automatically
20  *        handle the null-terminator.
21  * 
22  * @param dest 
23  * @param src 
24  * @param n 
25  * @return char* 
26  */
27 char* _weak
28 strncpy(char* dest, const char* src, unsigned long n)
29 {
30     char c = '\0';
31     unsigned int i = 0;
32     while (i < n && (c = src[i]))
33         dest[i++] = c;
34
35     while (i < n)
36         dest[i++] = 0;
37     
38     return dest;
39 }