svn commit: r243898 - head/usr.sbin/pw
Eitan Adler
eadler at FreeBSD.org
Wed Dec 5 13:56:56 UTC 2012
Author: eadler
Date: Wed Dec 5 13:56:56 2012
New Revision: 243898
URL: http://svnweb.freebsd.org/changeset/base/243898
Log:
Simplify string duplication: use strdup instead of malloc + strcpy
Submitted by: db
Approved by: cperciva
MFC after: 2 weeks
Modified:
head/usr.sbin/pw/grupd.c
Modified: head/usr.sbin/pw/grupd.c
==============================================================================
--- head/usr.sbin/pw/grupd.c Wed Dec 5 13:56:52 2012 (r243897)
+++ head/usr.sbin/pw/grupd.c Wed Dec 5 13:56:56 2012 (r243898)
@@ -50,12 +50,11 @@ setgrdir(const char * dir)
{
if (dir == NULL)
return -1;
- else {
- char * d = malloc(strlen(dir)+1);
- if (d == NULL)
- return -1;
- grpath = strcpy(d, dir);
- }
+ else
+ grpath = strdup(dir);
+ if (grpath == NULL)
+ return -1;
+
return 0;
}
More information about the svn-src-all
mailing list