From 20e86659c3fd0f83ace731524e88f6cef8fd98a3 Mon Sep 17 00:00:00 2001 From: Christian Schlittchen Date: Sun, 21 Apr 2002 08:22:58 +0000 Subject: [PATCH] =?UTF-8?q?-=20strncpy=20replacement.=20ca.=2050%=20schnel?= =?UTF-8?q?ler,=20weil=20kein=20=C3=BCberfl=C3=BCssiges=20=090-padding.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/util/strncpy.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/common/util/strncpy.c diff --git a/src/common/util/strncpy.c b/src/common/util/strncpy.c new file mode 100644 index 000000000..4c26718a0 --- /dev/null +++ b/src/common/util/strncpy.c @@ -0,0 +1,22 @@ + +/* + * Faster replacement for ISO-C strncpy, does not pad with zeros + */ + +#include + +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; +} +