tree-wide: use free_and_strdup()

Use free_and_strdup() where appropriate and replace equivalent,
open-coded versions.
This commit is contained in:
Daniel Mack
2015-07-30 13:09:01 +02:00
parent 5f17089ac1
commit 2fc09a9cdd
10 changed files with 40 additions and 59 deletions
+6 -5
View File
@@ -891,8 +891,10 @@ static int add_user(Item *i) {
i->uid = p->pw_uid;
i->uid_set = true;
free(i->description);
i->description = strdup(p->pw_gecos);
r = free_and_strdup(&i->description, p->pw_gecos);
if (r < 0)
return log_oom();
return 0;
}
if (!IN_SET(errno, 0, ENOENT))
@@ -1149,9 +1151,8 @@ static int process_item(Item *i) {
}
if (i->gid_path) {
free(j->gid_path);
j->gid_path = strdup(i->gid_path);
if (!j->gid_path)
r = free_and_strdup(&j->gid_path, i->gid_path);
if (r < 0)
return log_oom();
}