use calloc_a
authorFelix Fietkau <nbd@openwrt.org>
Mon, 31 Dec 2012 15:18:32 +0000 (16:18 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Mon, 31 Dec 2012 15:18:32 +0000 (16:18 +0100)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
procd.h
service.c

diff --git a/procd.h b/procd.h
index 6461be66b3180f396af244d699daffaf8aca2036..66a08e2d125f7f765f252e19fce0b988e7424030 100644 (file)
--- a/procd.h
+++ b/procd.h
@@ -2,6 +2,7 @@
 #define __PROCD_H
 
 #include <libubox/uloop.h>
+#include <libubox/utils.h>
 #include <libubus.h>
 #include <stdio.h>
 
index 8dbb1e6a22fa3ec3a788212bf3c2e1976733ef78..44b10bef39481ccb5eda59a01086c222f804ea62 100644 (file)
--- a/service.c
+++ b/service.c
@@ -54,9 +54,7 @@ service_alloc(const char *name)
        struct service *s;
        char *new_name;
 
-       s = calloc(1, sizeof(*s) + strlen(name) + 1);
-
-       new_name = (char *) (s + 1);
+       s = calloc_a(sizeof(*s), &new_name, strlen(name) + 1);
        strcpy(new_name, name);
 
        vlist_init(&s->instances, avl_strcmp, service_instance_update);