Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Apr 2012 04:29:17 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r233933 - stable/9/libexec/rtld-elf
Message-ID:  <201204060429.q364TH2b091534@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201204060429.q364TH2b091534>