1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-10 01:17:44 +03:00

sd-event: simplify sd_event_source_set_name()

free_and_strdup() does exactly the same as sd_event_source_set_name(), use
it!
This commit is contained in:
David Herrmann 2014-08-28 22:44:28 +02:00
parent 9021bb9f93
commit 32b13b2f58

View File

@ -1227,20 +1227,9 @@ _public_ sd_event_source* sd_event_source_unref(sd_event_source *s) {
} }
_public_ int sd_event_source_set_name(sd_event_source *s, const char *name) { _public_ int sd_event_source_set_name(sd_event_source *s, const char *name) {
char *new_name = NULL;
assert_return(s, -EINVAL); assert_return(s, -EINVAL);
if (name) { return free_and_strdup(&s->name, name);
new_name = strdup(name);
if (!new_name)
return -ENOMEM;
}
free(s->name);
s->name = new_name;
return 0;
} }
_public_ int sd_event_source_get_name(sd_event_source *s, const char **name) { _public_ int sd_event_source_get_name(sd_event_source *s, const char **name) {