From 5ebc65ad1cb4dbb699e760c6a4c6b5b52efa94e0 Mon Sep 17 00:00:00 2001 From: Eitan Adler 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 --- pw/grupd.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'pw/grupd.c') diff --git a/pw/grupd.c b/pw/grupd.c index e9f6b5e..3f78e95 100644 --- a/pw/grupd.c +++ b/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.2.3-56-ge451