From 3b3a43cfae6d7fe5f9b4c46a6dc2e8e7e92008a6 Mon Sep 17 00:00:00 2001 From: eadler Date: Wed, 5 Dec 2012 13:56:56 +0000 Subject: Simplify string duplication: use strdup instead of malloc + strcpy Submitted by: db Approved by: cperciva MFC after: 2 weeks --- usr.sbin/pw/grupd.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'usr.sbin/pw') diff --git a/usr.sbin/pw/grupd.c b/usr.sbin/pw/grupd.c index e9f6b5e..3f78e95 100644 --- a/usr.sbin/pw/grupd.c +++ b/usr.sbin/pw/grupd.c @@ -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; } -- cgit v1.1