service: use calloc instead of malloc+memset
authorFelix Fietkau <nbd@openwrt.org>
Tue, 3 Jun 2014 22:11:03 +0000 (00:11 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Tue, 3 Jun 2014 22:11:03 +0000 (00:11 +0200)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
service.c

index 354099b..486a1fb 100644 (file)
--- a/service.c
+++ b/service.c
@@ -135,11 +135,10 @@ service_send_srv(struct uloop_fd *u, struct service *s)
        if (len < 1)
                return;
 
        if (len < 1)
                return;
 
-       sd = malloc(len + sizeof(struct dns_srv_data));
+       sd = calloc(1, len + sizeof(struct dns_srv_data));
        if (!sd)
                return;
 
        if (!sd)
                return;
 
-       memset(sd, 0, sizeof(struct dns_srv_data));
        sd->port = cpu_to_be16(s->port);
        memcpy(&sd[1], buffer, len);
        host = service_name(s->service);
        sd->port = cpu_to_be16(s->port);
        memcpy(&sd[1], buffer, len);
        host = service_name(s->service);