summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-09-22 12:34:37 +0200
committerThomas Haller <thaller@redhat.com>2015-09-23 16:09:43 +0200
commit41917a52c085b8699e5b37ef9b574ee265dcd0bf (patch)
treedbd35d2dd4a5139569d0524eaf5c388117a7242f
parentd6370d09e6aa158d4fc7fe1e2ce4c335eed1e017 (diff)
downloadNetworkManager-41917a52c085b8699e5b37ef9b574ee265dcd0bf.tar.gz
systemd/adapt: refactor creation of struct sd_event_source
-rw-r--r--src/systemd/nm-sd-adapt.c16
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;