Never write your own stringlib function. They're always wrong.
authorDavid Given <dg@cowlark.com>
Sun, 15 Mar 2015 21:32:23 +0000 (22:32 +0100)
committerDavid Given <dg@cowlark.com>
Sun, 15 Mar 2015 21:32:23 +0000 (22:32 +0100)
--HG--
extra : source : edba20538064196b2309e94b20e085b51024ea88

Library/libs/strlen.c

index 98c1e27..a0e6c01 100644 (file)
@@ -1,16 +1,17 @@
-/* string.c
- * Copyright (C) 1995,1996 Robert de Bath <rdebath@cix.compulink.co.uk>
- * This file is part of the Linux-8086 C library and is distributed
- * under the GNU Library General Public License.
+/*
+ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ * This file is licensed under the terms of the MIT open source license.
  */
 
-#include <string.h>
+#include       <string.h>
 
-/********************** Function strlen ************************************/
-size_t strlen(const char *str)
+size_t
+strlen(const char *org)
 {
-       const char* start = str;
-       while (*str++)
-               ;
-       return str - start;
+       register const char *s = org;
+
+       while (*s++)
+               /* EMPTY */ ;
+
+       return --s - org;
 }