- strncpy replacement. ca. 50% schneller, weil kein überflüssiges

0-padding.
This commit is contained in:
Christian Schlittchen 2002-04-21 08:22:58 +00:00
parent 238cc9c778
commit 20e86659c3

22
src/common/util/strncpy.c Normal file
View file

@ -0,0 +1,22 @@
/*
* Faster replacement for ISO-C strncpy, does not pad with zeros
*/
#include <sys/types.h>
char *
strncpy(char *to, const char *from, size_t size)
{
char *t = to, *f = (char *)from;
int copied = 0;
while(copied < size) {
*t = *f;
if(*f == '\0') break;
t++; f++; copied++;
}
return to;
}