Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 May 2014 05:44:55 +0000 (UTC)
From:      Eitan Adler <eadler@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r265903 - head/usr.bin/units
Message-ID:  <201405120544.s4C5itsd027614@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: eadler
Date: Mon May 12 05:44:55 2014
New Revision: 265903
URL: http://svnweb.freebsd.org/changeset/base/265903

Log:
  units(1): use common functions
  
  No need to replicate strdup

Modified:
  head/usr.bin/units/units.c

Modified: head/usr.bin/units/units.c
==============================================================================
--- head/usr.bin/units/units.c	Mon May 12 04:30:53 2014	(r265902)
+++ head/usr.bin/units/units.c	Mon May 12 05:44:55 2014	(r265903)
@@ -111,10 +111,9 @@ dupstr(const char *str)
 {
 	char *ret;
 
-	ret = malloc(strlen(str) + 1);
+	ret = strdup(str);
 	if (!ret)
-		errx(3, "memory allocation error");
-	strcpy(ret, str);
+		err(3, "dupstr");
 	return (ret);
 }
 



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