diff options
author | Thomas Haller <thaller@redhat.com> | 2015-09-22 12:34:37 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-09-23 16:09:43 +0200 |
commit | 41917a52c085b8699e5b37ef9b574ee265dcd0bf (patch) | |
tree | dbd35d2dd4a5139569d0524eaf5c388117a7242f | |
parent | d6370d09e6aa158d4fc7fe1e2ce4c335eed1e017 (diff) | |
download | NetworkManager-41917a52c085b8699e5b37ef9b574ee265dcd0bf.tar.gz |
systemd/adapt: refactor creation of struct sd_event_source
-rw-r--r-- | src/systemd/nm-sd-adapt.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/systemd/nm-sd-adapt.c b/src/systemd/nm-sd-adapt.c index a6d817278e..7984dcba59 100644 --- a/src/systemd/nm-sd-adapt.c +++ b/src/systemd/nm-sd-adapt.c @@ -37,6 +37,16 @@ struct sd_event_source { sd_event_time_handler_t time_cb; }; +static struct sd_event_source * +source_new (void) +{ + struct sd_event_source *source; + + source = g_new0 (struct sd_event_source, 1); + source->refcount = 1; + return source; +} + int sd_event_source_set_priority (sd_event_source *s, int64_t priority) { @@ -113,8 +123,7 @@ sd_event_add_io (sd_event *e, sd_event_source **s, int fd, uint32_t events, sd_e if (!channel) return -EINVAL; - source = g_new0 (struct sd_event_source, 1); - source->refcount = 1; + source = source_new (); source->io_cb = callback; source->user_data = userdata; source->channel = channel; @@ -158,8 +167,7 @@ sd_event_add_time(sd_event *e, sd_event_source **s, clockid_t clock, uint64_t us struct sd_event_source *source; uint64_t n = now (clock); - source = g_new0 (struct sd_event_source, 1); - source->refcount = 1; + source = source_new (); source->time_cb = callback; source->user_data = userdata; source->usec = usec; |