fix compile on 64bit
[platform/upstream/libsolv.git] / tools / repo_rpmmd.c
index c77527f..44ab8ee 100644 (file)
@@ -702,9 +702,8 @@ startElement(void *userData, const char *name, const char **atts)
           /* this is a new package */
           pd->solvable = pool_id2solvable(pool, repo_add_solvable(pd->common.repo));
           pd->freshens = 0;
-          repodata_extend(pd->data, pd->solvable - pool->solvables);
         }
-      pd->handle = repodata_get_handle(pd->data, (pd->solvable - pool->solvables) - pd->data->start);
+      pd->handle = pd->solvable - pool->solvables;
 #if 0
       fprintf(stderr, "package #%d\n", pd->solvable - pool->solvables);
 #endif
@@ -774,19 +773,7 @@ startElement(void *userData, const char *name, const char **atts)
     case STATE_LOCATION:
       str = find_attr("href", atts);
       if (str)
-       {
-         const char *str2 = strrchr(str, '/');
-         if (str2)
-           {
-             char *str3 = strdup(str);
-             str3[str2 - str] = 0;
-             repodata_set_poolstr(pd->data, handle, SOLVABLE_MEDIADIR, str3);
-             free(str3);
-              repodata_set_str(pd->data, handle, SOLVABLE_MEDIAFILE, str2 + 1);
-           }
-         else
-            repodata_set_str(pd->data, handle, SOLVABLE_MEDIAFILE, str);
-       }
+       repodata_set_location(pd->data, handle, 0, 0, str);
       break;
     case STATE_CHECKSUM:
       pd->tmpattr = find_attr("type", atts);
@@ -1104,6 +1091,14 @@ repo_add_rpmmd(Repo *repo, FILE *fp, const char *language, int flags)
   char buf[BUFF_SIZE];
   int i, l;
   struct stateswitch *sw;
+  Repodata *data;
+  unsigned int now;
+
+  now = sat_timems(0);
+  if (!(flags & REPO_REUSE_REPODATA))
+    data = repo_add_repodata(repo, 0);
+  else
+    data = repo_last_repodata(repo);
 
   memset(&pd, 0, sizeof(pd));
   for (i = 0, sw = stateswitches; sw->from != NUMSTATES; i++, sw++)
@@ -1115,7 +1110,7 @@ repo_add_rpmmd(Repo *repo, FILE *fp, const char *language, int flags)
   pd.common.pool = pool;
   pd.common.repo = repo;
 
-  pd.data = repo_add_repodata(repo, 0);
+  pd.data = data;
 
   pd.content = sat_malloc(256);
   pd.acontent = 256;
@@ -1147,11 +1142,13 @@ repo_add_rpmmd(Repo *repo, FILE *fp, const char *language, int flags)
        break;
     }
   XML_ParserFree(parser);
-
-  if (pd.data)
-    repodata_internalize(pd.data);
   sat_free(pd.content);
   join_freemem();
   stringpool_free(&pd.cspool);
   sat_free(pd.cscache);
+  if (!(flags & REPO_NO_INTERNALIZE))
+    repodata_internalize(data);
+  POOL_DEBUG(SAT_DEBUG_STATS, "repo_add_rpmmd took %d ms\n", sat_timems(now));
+  POOL_DEBUG(SAT_DEBUG_STATS, "repo size: %d solvables\n", repo->nsolvables);
+  POOL_DEBUG(SAT_DEBUG_STATS, "repo memory used: %ld K incore, %ld K idarray\n", (unsigned long)data->incoredatalen/1024, (unsigned long)repo->idarraysize / (1024/sizeof(Id)));
 }