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/pkg_parse.c') diff --git a/libopkg/pkg_parse.c b/libopkg/pkg_parse.c index af5ead7..76cd648 100644 --- a/libopkg/pkg_parse.c +++ b/libopkg/pkg_parse.c @@ -141,7 +141,7 @@ int parseVersion(pkg_t *pkg, char *raw) if (!pkg->version) { - pkg->version= malloc(strlen(raw)+1); + pkg->version= calloc(1, strlen(raw)+1); if ( pkg->version == NULL ) { fprintf(stderr, "%s: out of memory \n", __FUNCTION__); return ENOMEM; @@ -230,7 +230,7 @@ int pkg_parse_raw(pkg_t *pkg, char ***raw, pkg_src_t *src, pkg_dest_t *dest) pkg->priority = parseGenericFieldType("Priority", *lines); else if(isGenericFieldType("Provides", *lines)){ /* Here we add the internal_use to align the off by one problem between provides_str and provides */ - provide = (char * ) malloc(strlen(*lines)+ 35 ); /* Preparing the space for the new opkg_internal_use_only */ + provide = (char * ) calloc(1, strlen(*lines)+ 35 ); /* Preparing the space for the new opkg_internal_use_only */ if ( alterProvidesLine(*lines,provide) ){ return EINVAL; } @@ -373,7 +373,7 @@ out:; if ( pkg_false_provides==1) { pkg->provides_count = 1; - pkg->provides_str = malloc (sizeof (char*)); + pkg->provides_str = calloc (1, sizeof (char*)); pkg->provides_str[0] = strdup ("opkg_internal_use_only"); } -- cgit v0.9.1