diff options
author | Eitan Adler <eadler@FreeBSD.org> | 2012-12-05 13:56:56 +0000 |
---|---|---|
committer | Eitan Adler <eadler@FreeBSD.org> | 2012-12-05 13:56:56 +0000 |
commit | 272e225a6ba49cf949fc263c3dcd7e74152ffdc2 (patch) | |
tree | 811c07df337d7bb71ec6a2a33339b4a1a96fbaa3 /pw | |
parent | 20929a4bb15d04607a63dc41ee257643f1c9181a (diff) | |
download | pw-darwin-272e225a6ba49cf949fc263c3dcd7e74152ffdc2.tar.gz pw-darwin-272e225a6ba49cf949fc263c3dcd7e74152ffdc2.tar.zst pw-darwin-272e225a6ba49cf949fc263c3dcd7e74152ffdc2.zip |
Simplify string duplication: use strdup instead of malloc + strcpy
Submitted by: db
Approved by: cperciva
MFC after: 2 weeks
Diffstat (limited to 'pw')
-rw-r--r-- | pw/grupd.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -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; } |