The compiler almost certainly knows better.
[oweals/opkg-lede.git] / libopkg / pkg_depends.c
index 49962ba5efeb957ada4b19e945daa6f0778252be..e5c50c94d2786a2fa29392a382337f8968d796c2 100644 (file)
@@ -56,7 +56,7 @@ int pkg_hash_fetch_unsatisfied_dependencies(opkg_conf_t *conf, pkg_t * pkg,
                                            pkg_vec_t *unsatisfied, char *** unresolved)
 {
      pkg_t * satisfier_entry_pkg;
-     register int i, j, k;
+     int i, j, k;
      int count, found;
      char ** the_lost;
      abstract_pkg_t * ab_pkg;
@@ -280,7 +280,7 @@ pkg_vec_t * pkg_hash_fetch_conflicts(hash_table_t * hash, pkg_t * pkg)
     compound_depend_t * conflicts;
     depend_t ** possible_satisfiers;
     depend_t * possible_satisfier;
-    register int i, j, k;
+    int i, j, k;
     int count;
     abstract_pkg_t * ab_pkg;
     pkg_t **pkg_scouts; 
@@ -437,7 +437,7 @@ int pkg_dependence_satisfied(opkg_conf_t *conf, depend_t *depend)
 
 static int is_pkg_in_pkg_vec(pkg_vec_t * vec, pkg_t * pkg)
 {
-    register int i;
+    int i;
     pkg_t ** pkgs = vec->pkgs;
 
     for(i = 0; i < vec->len; i++)
@@ -568,7 +568,7 @@ static char ** merge_unresolved(char ** oldstuff, char ** newstuff)
 {
     int oldlen = 0, newlen = 0;
     char ** result;
-    register int i, j;
+    int i, j;
 
     if(!newstuff)
        return oldstuff;
@@ -617,7 +617,7 @@ char ** add_unresolved_dep(pkg_t * pkg, char ** the_lost, int ref_ndx)
        
 void printDepends(pkg_t * pkg)
 {
-    register int i, j;
+    int i, j;
     compound_depend_t * depend;
     int count;
     
@@ -643,7 +643,7 @@ void printDepends(pkg_t * pkg)
 
 int buildProvides(hash_table_t * hash, abstract_pkg_t * ab_pkg, pkg_t * pkg)
 {
-    register int i, j;
+    int i, j;
 
     /* every pkg provides itself */
     abstract_pkg_vec_insert(ab_pkg->provided_by, ab_pkg);
@@ -653,7 +653,7 @@ int buildProvides(hash_table_t * hash, abstract_pkg_t * ab_pkg, pkg_t * pkg)
     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 ;
@@ -677,14 +677,13 @@ int buildProvides(hash_table_t * hash, abstract_pkg_t * ab_pkg, pkg_t * pkg)
 /* Abhaya: added conflicts support */
 int buildConflicts(hash_table_t * hash, abstract_pkg_t * ab_pkg, pkg_t * pkg)
 {
-    register int i;
+    int i;
     compound_depend_t * conflicts;
 
     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;
@@ -700,12 +699,12 @@ int buildConflicts(hash_table_t * hash, abstract_pkg_t * ab_pkg, pkg_t * pkg)
 
 int buildReplaces(hash_table_t * hash, abstract_pkg_t * ab_pkg, pkg_t * pkg)
 {
-     register int i, j;
+     int i, j;
 
      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;
@@ -734,7 +733,7 @@ int buildReplaces(hash_table_t * hash, abstract_pkg_t * ab_pkg, pkg_t * pkg)
 int buildDepends(hash_table_t * hash, pkg_t * pkg)
 {
      int count;
-     register int i;
+     int i;
      compound_depend_t * depends;
 
      if(!(count = pkg->pre_depends_count + pkg->depends_count + pkg->recommends_count + pkg->suggests_count))
@@ -743,7 +742,7 @@ int buildDepends(hash_table_t * hash, pkg_t * pkg)
      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;
@@ -840,7 +839,7 @@ void buildDependedUponBy(pkg_t * pkg, abstract_pkg_t * ab_pkg)
 {
      compound_depend_t * depends;
      int count, othercount;
-     register int i, j;
+     int i, j;
      abstract_pkg_t * ab_depend;
      abstract_pkg_t ** temp;
 
@@ -878,7 +877,7 @@ void buildDependedUponBy(pkg_t * pkg, abstract_pkg_t * ab_pkg)
 
 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; 
@@ -900,8 +899,8 @@ static int parseDepends(compound_depend_t *compound_depend,
 {
      char * pkg_name, buffer[2048];
      int num_of_ors = 0;
-     register int i;
-     register char * src, * dest;
+     int i;
+     char * src, * dest;
      depend_t ** possibilities;
 
      /* first count the number of ored possibilities for satisfying dependency */
@@ -913,7 +912,7 @@ static int parseDepends(compound_depend_t *compound_depend,
      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;