r4838 - trunk/src/target/opkg/libopkg

tick at docs.openmoko.org tick at docs.openmoko.org
Mon Dec 1 10:19:19 CET 2008


Author: tick
Date: 2008-12-01 10:19:17 +0100 (Mon, 01 Dec 2008)
New Revision: 4838

Modified:
   trunk/src/target/opkg/libopkg/file_util.c
   trunk/src/target/opkg/libopkg/hash_table.c
   trunk/src/target/opkg/libopkg/hash_table.h
   trunk/src/target/opkg/libopkg/nv_pair_list.c
   trunk/src/target/opkg/libopkg/opkg.c
   trunk/src/target/opkg/libopkg/opkg_cmd.c
   trunk/src/target/opkg/libopkg/opkg_conf.c
   trunk/src/target/opkg/libopkg/opkg_install.c
   trunk/src/target/opkg/libopkg/opkg_remove.c
   trunk/src/target/opkg/libopkg/opkg_utils.c
   trunk/src/target/opkg/libopkg/pkg.c
   trunk/src/target/opkg/libopkg/pkg_depends.c
   trunk/src/target/opkg/libopkg/pkg_dest_list.c
   trunk/src/target/opkg/libopkg/pkg_parse.c
   trunk/src/target/opkg/libopkg/pkg_src_list.c
   trunk/src/target/opkg/libopkg/pkg_vec.c
   trunk/src/target/opkg/libopkg/sprintf_alloc.c
   trunk/src/target/opkg/libopkg/str_list.c
   trunk/src/target/opkg/libopkg/void_list.c
   trunk/src/target/opkg/libopkg/xregex.c
Log:
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


Modified: trunk/src/target/opkg/libopkg/file_util.c
===================================================================
--- trunk/src/target/opkg/libopkg/file_util.c	2008-11-28 02:11:39 UTC (rev 4837)
+++ trunk/src/target/opkg/libopkg/file_util.c	2008-12-01 09:19:17 UTC (rev 4838)
@@ -143,7 +143,7 @@
     char *md5sum_hex;
     unsigned char md5sum_bin[md5sum_bin_len];
 
-    md5sum_hex = malloc(md5sum_hex_len + 1);
+    md5sum_hex = calloc(1, md5sum_hex_len + 1);
     if (md5sum_hex == NULL) {
 	fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
 	return strdup("");

Modified: trunk/src/target/opkg/libopkg/hash_table.c
===================================================================
--- trunk/src/target/opkg/libopkg/hash_table.c	2008-11-28 02:11:39 UTC (rev 4837)
+++ trunk/src/target/opkg/libopkg/hash_table.c	2008-12-01 09:19:17 UTC (rev 4838)
@@ -146,7 +146,7 @@
                         return 0;
                     }
                }
-	       hash_entry->next = (hash_entry_t *)malloc(sizeof(hash_entry_t));
+	       hash_entry->next = (hash_entry_t *)calloc(1, sizeof(hash_entry_t));
 	       if (!hash_entry->next) {
 		    return -ENOMEM;
 	       }
@@ -161,6 +161,37 @@
      return 0;
 }
 
+int hash_table_remove(hash_table_t *hash, const char *key)
+{
+    int ndx= hash_index(hash, key);
+    hash_entry_t *hash_entry = hash->entries + ndx;
+    hash_entry_t *next_entry=NULL, *last_entry=NULL;
+    while (hash_entry) 
+    {
+        if (hash_entry->key) 
+        {
+            if (strcmp(key, hash_entry->key) == 0) {
+                free(hash_entry->key);
+                if (last_entry) {
+                    last_entry->next = hash_entry->next;
+                    free(hash_entry);
+                } else {
+                    next_entry = hash_entry->next;
+                    if (next_entry) {
+                        memmove(hash_entry, next_entry, sizeof(hash_entry_t));
+                        free(next_entry);
+                    } else {
+                        memset(hash_entry, 0 , sizeof(hash_entry_t));
+                    }
+                }
+                return 1;
+            }
+        }
+        last_entry = hash_entry;
+        hash_entry = hash_entry->next;
+    }
+    return 0;
+}
 
 void hash_table_foreach(hash_table_t *hash, void (*f)(const char *key, void *entry, void *data), void *data)
 { 

Modified: trunk/src/target/opkg/libopkg/hash_table.h
===================================================================
--- trunk/src/target/opkg/libopkg/hash_table.h	2008-11-28 02:11:39 UTC (rev 4837)
+++ trunk/src/target/opkg/libopkg/hash_table.h	2008-12-01 09:19:17 UTC (rev 4838)
@@ -39,6 +39,7 @@
 void hash_table_deinit(hash_table_t *hash);
 void *hash_table_get(hash_table_t *hash, const char *key);
 int hash_table_insert(hash_table_t *hash, const char *key, void *value);
+int hash_table_remove(hash_table_t *has, const char *key);
 void hash_table_foreach(hash_table_t *hash, void (*f)(const char *key, void *entry, void *data), void *data);
 
 #endif /* _HASH_TABLE_H_ */

Modified: trunk/src/target/opkg/libopkg/nv_pair_list.c
===================================================================
--- trunk/src/target/opkg/libopkg/nv_pair_list.c	2008-11-28 02:11:39 UTC (rev 4837)
+++ trunk/src/target/opkg/libopkg/nv_pair_list.c	2008-12-01 09:19:17 UTC (rev 4838)
@@ -57,7 +57,7 @@
     int err;
 
     /* freed in nv_pair_list_deinit */
-    nv_pair_t *nv_pair = malloc(sizeof(nv_pair_t));
+    nv_pair_t *nv_pair = calloc(1, sizeof(nv_pair_t));
 
     if (nv_pair == NULL) {
 	fprintf(stderr, "%s: out of memory\n", __FUNCTION__);

Modified: trunk/src/target/opkg/libopkg/opkg.c
===================================================================
--- trunk/src/target/opkg/libopkg/opkg.c	2008-11-28 02:11:39 UTC (rev 4837)
+++ trunk/src/target/opkg/libopkg/opkg.c	2008-12-01 09:19:17 UTC (rev 4838)
@@ -163,8 +163,7 @@
 
   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_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 @@
     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)
   {

Modified: trunk/src/target/opkg/libopkg/opkg_cmd.c
===================================================================
--- trunk/src/target/opkg/libopkg/opkg_cmd.c	2008-11-28 02:11:39 UTC (rev 4837)
+++ trunk/src/target/opkg/libopkg/opkg_cmd.c	2008-12-01 09:19:17 UTC (rev 4838)
@@ -316,7 +316,7 @@
     char *newpath;
     int gen;
 
-    ctx = malloc (sizeof (*ctx));
+    ctx = calloc (1, sizeof (*ctx));
     oldpath = getenv ("PATH");
     if (oldpath) {
         ctx->oldpath = strdup (oldpath);
@@ -925,7 +925,7 @@
         available = pkg_vec_alloc();
         pkg_hash_fetch_all_installed(&conf->pkg_hash, available);
         for (i=0; i < argc; i++) {
-           pkg_name = malloc(strlen(argv[i])+2);
+           pkg_name = calloc(1, strlen(argv[i])+2);
            strcpy(pkg_name,argv[i]);
            for (a=0; a < available->len; a++) {
                pkg = available->pkgs[a];
@@ -1086,7 +1086,7 @@
      size_t used_len;
      char *buff ;
 
-     buff = (char *)malloc(buff_len);
+     buff = (char *)calloc(1, buff_len);
      if ( buff == NULL ) {
         fprintf( stderr,"%s: Unable to allocate memory \n",__FUNCTION__);
         return ENOMEM;

Modified: trunk/src/target/opkg/libopkg/opkg_conf.c
===================================================================
--- trunk/src/target/opkg/libopkg/opkg_conf.c	2008-11-28 02:11:39 UTC (rev 4837)
+++ trunk/src/target/opkg/libopkg/opkg_conf.c	2008-12-01 09:19:17 UTC (rev 4838)
@@ -73,7 +73,7 @@
 	  { NULL }
      };
 
-     *options = (opkg_option_t *)malloc(sizeof(tmp));
+     *options = (opkg_option_t *)calloc(1, sizeof(tmp));
      if ( options == NULL ){
         fprintf(stderr,"%s: Unable to allocate memory\n",__FUNCTION__);
         return -1;
@@ -182,7 +182,7 @@
             lists_dir = tmp;
      }
 
-     pending_dir = malloc(strlen(lists_dir)+strlen("/pending")+5);
+     pending_dir = calloc(1, strlen(lists_dir)+strlen("/pending")+5);
      snprintf(pending_dir,strlen(lists_dir)+strlen("/pending") ,"%s%s",lists_dir,"/pending");
 
      conf->lists_dir = strdup(lists_dir);

Modified: trunk/src/target/opkg/libopkg/opkg_install.c
===================================================================
--- trunk/src/target/opkg/libopkg/opkg_install.c	2008-11-28 02:11:39 UTC (rev 4837)
+++ trunk/src/target/opkg/libopkg/opkg_install.c	2008-12-01 09:19:17 UTC (rev 4838)
@@ -597,7 +597,7 @@
         if (found)
             continue;
         d_str = old_pkg->depends_str[i];
-        buf = malloc (strlen (d_str) + 1);
+        buf = calloc (1, strlen (d_str) + 1);
         j=0;
         while (d_str[j] != '\0' && d_str[j] != ' ') {
             buf[j]=d_str[j];

Modified: trunk/src/target/opkg/libopkg/opkg_remove.c
===================================================================
--- trunk/src/target/opkg/libopkg/opkg_remove.c	2008-11-28 02:11:39 UTC (rev 4837)
+++ trunk/src/target/opkg/libopkg/opkg_remove.c	2008-12-01 09:19:17 UTC (rev 4838)
@@ -54,7 +54,7 @@
      /* if caller requested the set of installed dependents */
      if (pdependents) {
 	  int p = 0;
-	  abstract_pkg_t **dependents = (abstract_pkg_t **)malloc((n_installed_dependents+1)*sizeof(abstract_pkg_t *));
+	  abstract_pkg_t **dependents = (abstract_pkg_t **)calloc((n_installed_dependents+1), sizeof(abstract_pkg_t *));
 
           if ( dependents == NULL ){
               fprintf(stderr,"%s Unable to allocate memory. REPORT THIS BUG IN BUGZILLA PLEASE\n", __FUNCTION__);
@@ -181,7 +181,7 @@
     int x = 0;
     pkg_t *p;
     d_str = pkg->depends_str[i];
-    buffer = malloc (strlen (d_str) + 1);
+    buffer = calloc (1, strlen (d_str) + 1);
     if (!buffer)
     {
       fprintf(stderr,"%s Unable to allocate memory.\n", __FUNCTION__);

Modified: trunk/src/target/opkg/libopkg/opkg_utils.c
===================================================================
--- trunk/src/target/opkg/libopkg/opkg_utils.c	2008-11-28 02:11:39 UTC (rev 4837)
+++ trunk/src/target/opkg/libopkg/opkg_utils.c	2008-12-01 09:19:17 UTC (rev 4838)
@@ -61,7 +61,7 @@
      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 *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 @@
   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;

Modified: trunk/src/target/opkg/libopkg/pkg.c
===================================================================
--- trunk/src/target/opkg/libopkg/pkg.c	2008-11-28 02:11:39 UTC (rev 4837)
+++ trunk/src/target/opkg/libopkg/pkg.c	2008-12-01 09:19:17 UTC (rev 4838)
@@ -77,7 +77,7 @@
 {
      pkg_t *pkg;
 
-     pkg = malloc(sizeof(pkg_t));
+     pkg = calloc(1, sizeof(pkg_t));
      if (pkg == NULL) {
 	  fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
 	  return NULL;
@@ -429,7 +429,7 @@
 {
      abstract_pkg_t * ab_pkg;
 
-     ab_pkg = malloc(sizeof(abstract_pkg_t));
+     ab_pkg = calloc(1, sizeof(abstract_pkg_t));
 
      if (ab_pkg == NULL) {
 	  fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
@@ -461,7 +461,7 @@
      char **raw =NULL;
      char **raw_start=NULL; 
 
-     temp_str = (char *) malloc (strlen(pkg->dest->info_dir)+strlen(pkg->name)+12);
+     temp_str = (char *) calloc (1, strlen(pkg->dest->info_dir)+strlen(pkg->name)+12);
      if (temp_str == NULL ){
         opkg_message(conf, OPKG_INFO, "Out of memory in  %s\n", __FUNCTION__);
         return;
@@ -497,7 +497,7 @@
      char *line;
      char * buff;
 
-     buff = malloc(8192);
+     buff = calloc(1, 8192);
      if (buff == NULL) {
 	  fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
 	  return NULL;
@@ -1398,9 +1398,9 @@
      str_list_elt_t *iter;
 
      pkg->installed_files_ref_cnt--;
-     if (pkg->installed_files_ref_cnt > 0) {
+
+     if (pkg->installed_files_ref_cnt > 0)
 	  return 0;
-     }
 
      if (pkg->installed_files) {
 

Modified: trunk/src/target/opkg/libopkg/pkg_depends.c
===================================================================
--- trunk/src/target/opkg/libopkg/pkg_depends.c	2008-11-28 02:11:39 UTC (rev 4837)
+++ trunk/src/target/opkg/libopkg/pkg_depends.c	2008-12-01 09:19:17 UTC (rev 4838)
@@ -653,7 +653,7 @@
     if (pkg->provides)
       return 0;
 
-    pkg->provides = (abstract_pkg_t **)malloc(sizeof(abstract_pkg_t *) * (pkg->provides_count + 1));
+    pkg->provides = (abstract_pkg_t **)calloc((pkg->provides_count + 1), sizeof(abstract_pkg_t *));
     if (pkg->provides == NULL) {
        fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
        return -1 ;
@@ -683,8 +683,7 @@
     if (!pkg->conflicts_count)
 	return 0;
 
-    conflicts = pkg->conflicts = malloc(sizeof(compound_depend_t) *
-					pkg->conflicts_count);
+    conflicts = pkg->conflicts = calloc(pkg->conflicts_count, sizeof(compound_depend_t));
     if (conflicts == NULL) {
        fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
        return  -1;
@@ -705,7 +704,7 @@
      if (!pkg->replaces_count)
 	  return 0;
 
-     pkg->replaces = (abstract_pkg_t **)malloc(sizeof(abstract_pkg_t *) * pkg->replaces_count);
+     pkg->replaces = (abstract_pkg_t **)calloc(pkg->replaces_count, sizeof(abstract_pkg_t *));
      if (pkg->replaces == NULL) {
         fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
         return  -1;
@@ -743,7 +742,7 @@
      if (0 && pkg->pre_depends_count)
 	  fprintf(stderr, "pkg=%s pre_depends_count=%d depends_count=%d\n", 
 		  pkg->name, pkg->pre_depends_count, pkg->depends_count);
-     depends = pkg->depends = malloc(sizeof(compound_depend_t) * count);
+     depends = pkg->depends = calloc(count, sizeof(compound_depend_t));
      if (depends == NULL) {
         fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
         return  -1;
@@ -878,7 +877,7 @@
 
 static depend_t * depend_init(void)
 {
-    depend_t * d = (depend_t *)malloc(sizeof(depend_t));    
+    depend_t * d = (depend_t *)calloc(1, sizeof(depend_t));    
     if ( d==NULL ){
         fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
         return NULL; 
@@ -913,7 +912,7 @@
      compound_depend->type = DEPEND;
 
      compound_depend->possibility_count = num_of_ors + 1;
-     possibilities = (depend_t **)malloc(sizeof(depend_t *) * (num_of_ors + 1));
+     possibilities = (depend_t **)calloc((num_of_ors + 1), sizeof(depend_t *) );
      if (!possibilities)
 	  return -ENOMEM;
      compound_depend->possibilities = possibilities;

Modified: trunk/src/target/opkg/libopkg/pkg_dest_list.c
===================================================================
--- trunk/src/target/opkg/libopkg/pkg_dest_list.c	2008-11-28 02:11:39 UTC (rev 4837)
+++ trunk/src/target/opkg/libopkg/pkg_dest_list.c	2008-12-01 09:19:17 UTC (rev 4838)
@@ -59,7 +59,7 @@
     pkg_dest_t *pkg_dest;
 
     /* freed in plg_dest_list_deinit */
-    pkg_dest = malloc(sizeof(pkg_dest_t));
+    pkg_dest = calloc(1, sizeof(pkg_dest_t));
     if (pkg_dest == NULL) {
 	fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
 	return NULL;

Modified: trunk/src/target/opkg/libopkg/pkg_parse.c
===================================================================
--- trunk/src/target/opkg/libopkg/pkg_parse.c	2008-11-28 02:11:39 UTC (rev 4837)
+++ trunk/src/target/opkg/libopkg/pkg_parse.c	2008-12-01 09:19:17 UTC (rev 4838)
@@ -141,7 +141,7 @@
 
   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 @@
 		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 @@
     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");
     }
 

Modified: trunk/src/target/opkg/libopkg/pkg_src_list.c
===================================================================
--- trunk/src/target/opkg/libopkg/pkg_src_list.c	2008-11-28 02:11:39 UTC (rev 4837)
+++ trunk/src/target/opkg/libopkg/pkg_src_list.c	2008-12-01 09:19:17 UTC (rev 4838)
@@ -48,7 +48,7 @@
     int err;
 
     /* freed in pkg_src_list_deinit */
-    pkg_src_t *pkg_src = malloc(sizeof(pkg_src_t));
+    pkg_src_t *pkg_src = calloc(1, sizeof(pkg_src_t));
 
     if (pkg_src == NULL) {
 	fprintf(stderr, "%s: out of memory\n", __FUNCTION__);

Modified: trunk/src/target/opkg/libopkg/pkg_vec.c
===================================================================
--- trunk/src/target/opkg/libopkg/pkg_vec.c	2008-11-28 02:11:39 UTC (rev 4837)
+++ trunk/src/target/opkg/libopkg/pkg_vec.c	2008-12-01 09:19:17 UTC (rev 4838)
@@ -185,12 +185,9 @@
  */
 void abstract_pkg_vec_insert(abstract_pkg_vec_t *vec, abstract_pkg_t *pkg)
 {
-
-	vec->pkgs = 
-	  (abstract_pkg_t **)
-	    realloc(vec->pkgs, (vec->len + 1) * sizeof(abstract_pkg_t *));
-	vec->pkgs[vec->len] = pkg;
-	vec->len++;
+    vec->pkgs = (abstract_pkg_t **) realloc(vec->pkgs, (vec->len + 1) * sizeof(abstract_pkg_t *));
+    vec->pkgs[vec->len] = pkg;
+    vec->len++;
 }
 
 abstract_pkg_t * abstract_pkg_vec_get(abstract_pkg_vec_t *vec, int i)

Modified: trunk/src/target/opkg/libopkg/sprintf_alloc.c
===================================================================
--- trunk/src/target/opkg/libopkg/sprintf_alloc.c	2008-11-28 02:11:39 UTC (rev 4837)
+++ trunk/src/target/opkg/libopkg/sprintf_alloc.c	2008-12-01 09:19:17 UTC (rev 4838)
@@ -44,7 +44,7 @@
 
     /* ripped more or less straight out of PRINTF(3) */
 
-    if ((new_str = malloc(size)) == NULL) 
+    if ((new_str = calloc(1, size)) == NULL) 
       return -1;
 
     *str = new_str;

Modified: trunk/src/target/opkg/libopkg/str_list.c
===================================================================
--- trunk/src/target/opkg/libopkg/str_list.c	2008-11-28 02:11:39 UTC (rev 4837)
+++ trunk/src/target/opkg/libopkg/str_list.c	2008-12-01 09:19:17 UTC (rev 4838)
@@ -31,7 +31,7 @@
 
 str_list_t *str_list_alloc()
 {
-     str_list_t *list = (str_list_t *)malloc(sizeof(str_list_t));
+     str_list_t *list = (str_list_t *)calloc(1, sizeof(str_list_t));
      if (list)
 	  str_list_init(list);
      return list;

Modified: trunk/src/target/opkg/libopkg/void_list.c
===================================================================
--- trunk/src/target/opkg/libopkg/void_list.c	2008-11-28 02:11:39 UTC (rev 4837)
+++ trunk/src/target/opkg/libopkg/void_list.c	2008-12-01 09:19:17 UTC (rev 4838)
@@ -60,7 +60,7 @@
     void_list_elt_t *elt;
 
     /* freed in void_list_deinit */
-    elt = malloc(sizeof(void_list_elt_t));
+    elt = calloc(1, sizeof(void_list_elt_t));
     if (elt == NULL) {
 	fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
 	return ENOMEM;
@@ -84,7 +84,7 @@
 {
     void_list_elt_t *elt;
 
-    elt = malloc(sizeof(void_list_elt_t));
+    elt = calloc(1, sizeof(void_list_elt_t));
     if (elt == NULL) {
 	fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
 	return ENOMEM;

Modified: trunk/src/target/opkg/libopkg/xregex.c
===================================================================
--- trunk/src/target/opkg/libopkg/xregex.c	2008-11-28 02:11:39 UTC (rev 4837)
+++ trunk/src/target/opkg/libopkg/xregex.c	2008-12-01 09:19:17 UTC (rev 4838)
@@ -39,7 +39,7 @@
     
     fprintf(stderr, "%s: Error compiling regex:", __FUNCTION__);
     size = regerror(err, preg, 0, 0);
-    error = malloc(size);
+    error = calloc(1, size);
     if (error) {
 	regerror(err, preg, error, size);
 	fprintf(stderr, "%s\n", error);




More information about the commitlog mailing list