chiark / gitweb /
NEW etc.: Use NEW_ARY
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 7 Oct 2014 19:36:17 +0000 (20:36 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 21 Oct 2014 00:07:13 +0000 (01:07 +0100)
Replace all calls to safe_malloc_ary with the NEW_ARY wrapper.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
conffile.c
ipaddr.c
netlink.c
site.c

index 3ffbd9f..84f4960 100644 (file)
@@ -705,7 +705,7 @@ const char **dict_read_string_array(dict_t *dict, cstring_t key,
     }
 
     int32_t ll=list_length(l);
-    ra=safe_malloc_ary(sizeof(*ra), ll+1, "dict_read_string_array");
+    NEW_ARY(ra, ll+1);
     for (rap=ra; l; l=l->next,rap++) {
        item_t *it=l->item;
        if (it->type!=t_string)
index b3cd0a7..8bb2efc 100644 (file)
--- a/ipaddr.c
+++ b/ipaddr.c
@@ -18,7 +18,7 @@ struct subnet_list *subnet_list_new(void)
     NEW(r);
     r->entries=0;
     r->alloc=DEFAULT_ALLOC;
-    r->list=safe_malloc_ary(sizeof(*r->list),r->alloc,"subnet_list_new:data");
+    NEW_ARY(r->list,r->alloc);
     return r;
 }
 
index e180b1d..75763cf 100644 (file)
--- a/netlink.c
+++ b/netlink.c
@@ -1039,8 +1039,7 @@ static void netlink_phase_hook(void *sst, uint32_t new_phase)
     /* All the networks serviced by the various tunnels should now
      * have been registered.  We build a routing table by sorting the
      * clients by priority.  */
-    st->routes=safe_malloc_ary(sizeof(*st->routes),st->n_clients,
-                              "netlink_phase_hook");
+    NEW_ARY(st->routes,st->n_clients);
     /* Fill the table */
     i=0;
     for (c=st->clients; c; c=c->next) {
diff --git a/site.c b/site.c
index 94da06c..756ad35 100644 (file)
--- a/site.c
+++ b/site.c
@@ -1980,7 +1980,7 @@ static list_t *site_apply(closure_t *self, struct cloc loc, dict_t *context,
     if (!things##_cfg)                                                 \
        cfgfatal(loc,"site","closure list \"%s\" not found\n",dictkey); \
     st->nthings=list_length(things##_cfg);                             \
-    st->things=safe_malloc_ary(sizeof(*st->things),st->nthings,dictkey "s"); \
+    NEW_ARY(st->things,st->nthings);                                   \
     assert(st->nthings);                                               \
     for (i=0; i<st->nthings; i++) {                                    \
        item_t *item=list_elem(things##_cfg,i);                         \