diff options
author | Tom Gundersen <teg@jklm.no> | 2014-04-10 19:00:30 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-04-10 19:00:36 +0200 |
commit | 77768cbabc97d27535bd5329a11490f5c35a63f3 (patch) | |
tree | b759e58f6a1d0d3c7c52a3491e0f4fec2e0549a6 /src/libsystemd/sd-rtnl/sd-rtnl.c | |
parent | d47e1de40e410ab2149918c3269038d2c264b01d (diff) |
sd-rtnl: use GREEDY_REALLOC for message queues
Diffstat (limited to 'src/libsystemd/sd-rtnl/sd-rtnl.c')
-rw-r--r-- | src/libsystemd/sd-rtnl/sd-rtnl.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/libsystemd/sd-rtnl/sd-rtnl.c b/src/libsystemd/sd-rtnl/sd-rtnl.c index 2ab9d90aa7..8e709bb66d 100644 --- a/src/libsystemd/sd-rtnl/sd-rtnl.c +++ b/src/libsystemd/sd-rtnl/sd-rtnl.c @@ -51,8 +51,7 @@ static int sd_rtnl_new(sd_rtnl **ret) { /* We guarantee that wqueue always has space for at least * one entry */ - rtnl->wqueue = new(sd_rtnl_message*, 1); - if (!rtnl->wqueue) + if (!GREEDY_REALLOC(rtnl->wqueue, rtnl->wqueue_allocated, 1)) return -ENOMEM; *ret = rtnl; @@ -188,18 +187,14 @@ int sd_rtnl_send(sd_rtnl *nl, nl->wqueue_size = 1; } } else { - sd_rtnl_message **q; - /* append to queue */ if (nl->wqueue_size >= RTNL_WQUEUE_MAX) return -ENOBUFS; - q = realloc(nl->wqueue, sizeof(sd_rtnl_message*) * (nl->wqueue_size + 1)); - if (!q) + if (!GREEDY_REALLOC(nl->wqueue, nl->wqueue_allocated, nl->wqueue_size + 1)) return -ENOMEM; - nl->wqueue = q; - q[nl->wqueue_size ++] = sd_rtnl_message_ref(message); + nl->wqueue[nl->wqueue_size ++] = sd_rtnl_message_ref(message); } if (serial) |