From 733d8409723a397b4ced39ea7aaab8bc8b4af5d9 Mon Sep 17 00:00:00 2001 From: ticktock35 Date: Mon, 15 Dec 2008 00:30:29 -0500 Subject: opkg: adding the hash_table_remove API, not using yet. Just complete the API for future usage. Clean all the entry at initial time. This reduces planty of unnecessary check. In order to prevent this kind of bug, using calloc to replace most malloc git-svn-id: http://opkg.googlecode.com/svn/trunk@160 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358 --- (limited to 'libopkg/opkg.c') diff --git a/libopkg/opkg.c b/libopkg/opkg.c index 7e67755..35ddb89 100644 --- a/libopkg/opkg.c +++ b/libopkg/opkg.c @@ -163,8 +163,7 @@ opkg_package_new () opkg_package_t *p; - p = malloc (sizeof (opkg_package_t)); - memset (p, 0, sizeof (opkg_package_t)); + p = calloc (1, sizeof (opkg_package_t)); return p; } @@ -189,9 +188,9 @@ opkg_new () opkg_t *opkg; int err; - opkg = malloc (sizeof (opkg_t)); + opkg = calloc (1, sizeof (opkg_t)); - opkg->args = malloc (sizeof (args_t)); + opkg->args = calloc (1, sizeof (args_t)); err = args_init (opkg->args); if (err) { @@ -200,7 +199,7 @@ opkg_new () return NULL; } - opkg->conf = malloc (sizeof (opkg_conf_t)); + opkg->conf = calloc (1, sizeof (opkg_conf_t)); err = opkg_conf_init (opkg->conf, opkg->args); if (err) { -- cgit v0.9.1