summary refs log tree commit diff
path: root/include/string.h
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-08-30 23:22:02 +0000
committerUlrich Drepper <drepper@redhat.com>2001-08-30 23:22:02 +0000
commit5a3fba993001f71d2c50a1ea59dcc75a721b7ccd (patch)
treea1323cee4e72eaba3d1b8b2556c395a17557783d /include/string.h
parentee0cb67ec23814094bdc7ef973bd48f2ae7c649d (diff)
downloadglibc-5a3fba993001f71d2c50a1ea59dcc75a721b7ccd.tar.gz
glibc-5a3fba993001f71d2c50a1ea59dcc75a721b7ccd.tar.xz
glibc-5a3fba993001f71d2c50a1ea59dcc75a721b7ccd.zip
Update.
2001-08-30  Ulrich Drepper  <drepper@redhat.com>

	* string/argz-stringify.c (__argz_stringify): Use __strnlen
	instead of strnlen.
	* include/string.h (strndupa): Redefine here to use __strnlen
	instead of strnlen.
	* string/strndup.c (__strndup): Use __strnlen not strnlen.

	* misc/syslog.c (vsyslog): Fix typo in last change (connect ->
	connected).
Diffstat (limited to 'include/string.h')
-rw-r--r--include/string.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/string.h b/include/string.h
index 7d268ecfb1..8dda2f1b7e 100644
--- a/include/string.h
+++ b/include/string.h
@@ -47,4 +47,16 @@ extern char *__strerror_r (int __errnum, char *__buf, size_t __buflen);
 /* Now the real definitions.  We do this here since some of the functions
    above are defined as macros in the headers.  */
 #include <string/string.h>
+
+/* Alternative version which doesn't pollute glibc's namespace.  */
+#undef strndupa
+#define strndupa(s, n)							      \
+  (__extension__							      \
+    ({									      \
+      __const char *__old = (s);					      \
+      size_t __len = __strnlen (__old, (n));				      \
+      char *__new = (char *) __builtin_alloca (__len + 1);		      \
+      __new[__len] = '\0';						      \
+      (char *) memcpy (__new, __old, __len);				      \
+    }))
 #endif