svn commit: r233933 - stable/9/libexec/rtld-elf

Konstantin Belousov kib at FreeBSD.org
Fri Apr 6 04:29:18 UTC 2012


Author: kib
Date: Fri Apr  6 04:29:17 2012
New Revision: 233933
URL: http://svn.freebsd.org/changeset/base/233933

Log:
  MFC r233357:
  Implement xstrdup() using strlen()/xmalloc()/memcpy() already
  presented in rtld, instead of pulling in libc strdup().

Modified:
  stable/9/libexec/rtld-elf/xmalloc.c
Directory Properties:
  stable/9/libexec/rtld-elf/   (props changed)

Modified: stable/9/libexec/rtld-elf/xmalloc.c
==============================================================================
--- stable/9/libexec/rtld-elf/xmalloc.c	Fri Apr  6 00:03:45 2012	(r233932)
+++ stable/9/libexec/rtld-elf/xmalloc.c	Fri Apr  6 04:29:17 2012	(r233933)
@@ -57,12 +57,13 @@ xmalloc(size_t size)
 }
 
 char *
-xstrdup(const char *s)
+xstrdup(const char *str)
 {
-    char *p = strdup(s);
-    if (p == NULL) {
-	 rtld_fdputstr(STDERR_FILENO, "Out of memory\n");
-	 _exit(1);
-    }
-    return p;
+	char *copy;
+	size_t len;
+
+	len = strlen(str) + 1;
+	copy = xmalloc(len);
+	memcpy(copy, str, len);
+	return (copy);
 }


More information about the svn-src-all mailing list