From owner-svn-src-head@FreeBSD.ORG Fri Mar 23 12:04:44 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D9EBD1065673; Fri, 23 Mar 2012 12:04:44 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C57F88FC15; Fri, 23 Mar 2012 12:04:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q2NC4iTA075378; Fri, 23 Mar 2012 12:04:44 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q2NC4iTW075376; Fri, 23 Mar 2012 12:04:44 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201203231204.q2NC4iTW075376@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 23 Mar 2012 12:04:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r233357 - head/libexec/rtld-elf X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Mar 2012 12:04:45 -0000 Author: kib Date: Fri Mar 23 12:04:44 2012 New Revision: 233357 URL: http://svn.freebsd.org/changeset/base/233357 Log: Implement xstrdup() using strlen()/xmalloc()/memcpy() already presented in rtld, instead of pulling in libc strdup(). Submitted by: bde MFC after: 2 weeks Modified: head/libexec/rtld-elf/xmalloc.c Modified: head/libexec/rtld-elf/xmalloc.c ============================================================================== --- head/libexec/rtld-elf/xmalloc.c Fri Mar 23 12:02:00 2012 (r233356) +++ head/libexec/rtld-elf/xmalloc.c Fri Mar 23 12:04:44 2012 (r233357) @@ -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); }