summaryrefslogtreecommitdiffstats
path: root/libopkg/opkg_utils.c
diff options
context:
space:
mode:
authorticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2008-12-15 00:30:29 (EST)
committer ticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2008-12-15 00:30:29 (EST)
commit733d8409723a397b4ced39ea7aaab8bc8b4af5d9 (patch)
tree7138fbfc11577cf7d0fbae0ae7fa98a02ef63a8e /libopkg/opkg_utils.c
parent1cefade73444d4670d9ae7c06e8f9cc55492fd79 (diff)
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
Diffstat (limited to 'libopkg/opkg_utils.c')
-rw-r--r--libopkg/opkg_utils.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/libopkg/opkg_utils.c b/libopkg/opkg_utils.c
index de7712e..6a827e0 100644
--- a/libopkg/opkg_utils.c
+++ b/libopkg/opkg_utils.c
@@ -61,7 +61,7 @@ char **read_raw_pkgs_from_stream(FILE *fp)
int count = 0;
size_t size = 512;
- buf = malloc (size);
+ buf = calloc (1, size);
while (fgets(buf, size, fp)) {
while (strlen (buf) == (size - 1)
@@ -96,7 +96,7 @@ char *trim_alloc(char *line)
char *new;
char *dest, *src, *end;
- new = malloc(strlen(line) + 1);
+ new = calloc(1, strlen(line) + 1);
if ( new == NULL ){
fprintf(stderr,"%s: Unable to allocate memory\n",__FUNCTION__);
return NULL;
@@ -142,7 +142,7 @@ void push_error_list(struct errlist ** errors, char * msg){
struct errlist *err_lst_tmp;
- err_lst_tmp = malloc ( sizeof (err_lst_tmp) );
+ err_lst_tmp = calloc (1, sizeof (err_lst_tmp) );
err_lst_tmp->errmsg=strdup(msg) ;
err_lst_tmp->next = *errors;
*errors = err_lst_tmp;