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>
Thu, 9 Oct 2014 18:30:01 +0000 (19:30 +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 3ffbd9fd8274c2f3d3ceca8482770ae17951740d..84f496026148f89d6fddf00a60153071b9ea00f3 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 b3cd0a7bf55050c2957e72b341e838bb12e9bca1..8bb2efcedad3557c4a8525448496a74f2142e8d4 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 e180b1dfad95fb53f4f46e61516ae83440873538..75763cf520719fc1bfc2934da725344121c35aa0 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 94da06ccafd9b47f2e51d3e60e42589270a66b2d..756ad357775fbab3f359cad38cf4649657523921 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);                         \