Use calloc instead of malloc + memset.
authorRoy Marples <roy@marples.name>
Sat, 25 Jul 2009 22:07:51 +0000 (22:07 +0000)
committerRoy Marples <roy@marples.name>
Sat, 25 Jul 2009 22:07:51 +0000 (22:07 +0000)
src/libdhcpcd/main.c
src/libdhcpcd/wpa.c

index 6e4059e2dbb714e5e2a428062b585f0228a8e299..eef3ee8c56d4ba4f74a6699481ed0f12dd158168 100644 (file)
@@ -144,10 +144,9 @@ dhcpcd_open(char **error)
        }
        if (bus == NULL)
                return NULL;
-       con = malloc(sizeof(*con));
+       con = calloc(1, sizeof(*con));
        if (con == NULL)
                goto bad;
-       memset(con, 0, sizeof(*con));
        con->bus = bus;
        if (!dbus_connection_set_watch_functions(bus,
                dhcpcd_add_watch, dhcpcd_delete_watch, NULL, con, NULL))
@@ -406,12 +405,11 @@ dhcpcd_if_new(DHCPCD_CONNECTION *con, DBusMessageIter *array, char **order)
                return NULL;
        }
        dbus_message_iter_recurse(array, &dict);
-       i = malloc(sizeof(*i));
+       i = calloc(1, sizeof(*i));
        if (i == NULL) {
                dhcpcd_error_set(con, 0, errno);
                return NULL;
        }
-       memset(i, 0, sizeof(*i));
        errors = con->errors;
        for (;
             dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY;
index 6d2360125f0d37031f3e0f98d498902a16877503..c85f486f363e81b53eadf4db301a16ffbcb5d0cc 100644 (file)
@@ -67,12 +67,11 @@ dhcpcd_scanresult_new(DHCPCD_CONNECTION *con, DBusMessageIter *array)
        int32_t i32;
        int errors;
 
-       wis = malloc(sizeof(*wis));
+       wis = calloc(1, sizeof(*wis));
        if (wis == NULL) {
                dhcpcd_error_set(con, NULL, errno);
                return NULL;
        }
-       memset(wis, 0, sizeof(*wis));
        errors = con->errors;
        dbus_message_iter_recurse(array, &dict);
        for (;