mirror of
https://github.com/UzixLS/KernelEx.git
synced 2025-07-19 07:21:20 +03:00
import KernelEx-4.0-RC1
This commit is contained in:
24
kexcrt/strncpy.c
Normal file
24
kexcrt/strncpy.c
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* strncpy.c
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
char *strncpy(char *dst, const char *src, size_t n)
|
||||
{
|
||||
char *q = dst;
|
||||
const char *p = src;
|
||||
char ch;
|
||||
|
||||
while (n) {
|
||||
n--;
|
||||
*q++ = ch = *p++;
|
||||
if (!ch)
|
||||
break;
|
||||
}
|
||||
|
||||
/* The specs say strncpy() fills the entire buffer with NUL. Sigh. */
|
||||
memset(q, 0, n);
|
||||
|
||||
return dst;
|
||||
}
|
Reference in New Issue
Block a user