Skip to contentSkip to conversation

strnlen for klibc

PATCH Harald Hoyer 2 participants 2 messages Jul 15, 2004

lore
Share & tools
lore
#0 lore raw

this implements strnlen for klibc

klibc/klibc/strlen.c renamed from klibc/klibc/strlen.c.strnlen +10 -0
@@ -12,3 +12,13 @@
   return ss-s;
 }
 
+size_t strnlen(const char *s, size_t maxlen)
+{
+  const char *ss = s;
+  while(*ss && (maxlen > 0)) {
+	ss++;
+	maxlen--;
+  }
+  return ss-s;
+}
+
klibc/klibc/include/string.h renamed from klibc/klibc/include/string.h.strnlen +1 -0
@@ -27,6 +27,7 @@
 __extern char *strndup(const char *, size_t);
 __extern char *strerror(int);
 __extern size_t strlen(const char *);
+__extern size_t strnlen(const char *, size_t);
 __extern char *strncat(char *, const char *, size_t);
 __extern int strncmp(const char *, const char *, size_t);
 __extern char *strncpy(char *, const char *, size_t);
#1 lore raw
Quoted 2 lines · Harald Hoyer

this implements strnlen for klibc

Thanks. For future reference, please put independent functions in separate files as much as possible, since the linker links files, not functions.

Adjusted and applied.

-hpa

-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_idG21&alloc_id040&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel