From: krw Date: Mon, 5 May 2014 14:44:18 +0000 (+0000) Subject: A couple of malloc()+memset(0) -> calloc. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=6d189339c495029312c5782db5b6916a429ab37e;p=openbsd A couple of malloc()+memset(0) -> calloc. --- diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c index 31c1a39ce64..1632bd17ff7 100644 --- a/sbin/dhclient/clparse.c +++ b/sbin/dhclient/clparse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clparse.c,v 1.83 2014/01/25 05:21:23 krw Exp $ */ +/* $OpenBSD: clparse.c,v 1.84 2014/05/05 14:44:18 krw Exp $ */ /* Parser for dhclient config and lease files. */ @@ -454,12 +454,11 @@ parse_client_lease_statement(FILE *cfile, int is_static) return; } - lease = malloc(sizeof(struct client_lease)); + lease = calloc(1, sizeof(struct client_lease)); if (!lease) error("no memory for lease."); - memset(lease, 0, sizeof(*lease)); - lease->is_static = is_static; + lease->is_static = is_static; do { token = peek_token(NULL, cfile); if (token == EOF) { diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index e8fa989b994..8c4e3743094 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.301 2014/05/04 21:07:50 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.302 2014/05/05 14:44:18 krw Exp $ */ /* * Copyright 2004 Henning Brauer @@ -991,14 +991,12 @@ packet_to_lease(struct in_addr client_addr, struct option_data *options) char *pretty; int i; - lease = malloc(sizeof(struct client_lease)); + lease = calloc(1, sizeof(struct client_lease)); if (!lease) { warning("dhcpoffer: no memory to record lease."); return (NULL); } - memset(lease, 0, sizeof(*lease)); - /* Copy the lease options. */ for (i = 0; i < 256; i++) { if (options[i].len == 0)