reduce memory by splitting the pages array into two mapped_at and file_pages arrays
[platform/upstream/libsolv.git] / ext / repo_content.c
index 53ed304..75f339c 100644 (file)
@@ -28,6 +28,7 @@
 #include "chksum.h"
 #include "repo_content.h"
 #define DISABLE_SPLIT
+#define DISABLE_JOIN2
 #include "tools_util.h"
 
 /* split off a word, return null terminated pointer to it.
@@ -212,6 +213,7 @@ repo_add_content(Repo *repo, FILE *fp, int flags)
   char *defvendor = 0;
 
   int i = 0;
+  int res = 0;
 
   /* architectures
      we use the first architecture in BASEARCHS or noarch
@@ -297,7 +299,7 @@ repo_add_content(Repo *repo, FILE *fp, int flags)
                repodata_set_str(data, SOLVID_META, SUSETAGS_DESCRDIR, value);
              if (s)
                repodata_set_str(data, s - pool->solvables, SUSETAGS_DESCRDIR, value);
-             descrdir = strdup(value);
+             descrdir = solv_strdup(value);
              continue;
            }
          if (istag ("DATADIR"))
@@ -308,7 +310,7 @@ repo_add_content(Repo *repo, FILE *fp, int flags)
                repodata_set_str(data, SOLVID_META, SUSETAGS_DATADIR, value);
              if (s)
                repodata_set_str(data, s - pool->solvables, SUSETAGS_DATADIR, value);
-             datadir = strdup(value);
+             datadir = solv_strdup(value);
              continue;
            }
          if (istag ("VENDOR"))
@@ -319,7 +321,7 @@ repo_add_content(Repo *repo, FILE *fp, int flags)
                repodata_set_poolstr(data, SOLVID_META, SUSETAGS_DEFAULTVENDOR, value);
              if (s)
                s->vendor = pool_str2id(pool, value, 1);
-             defvendor = strdup(value);
+             defvendor = solv_strdup(value);
              continue;
            }
 
@@ -338,13 +340,15 @@ repo_add_content(Repo *repo, FILE *fp, int flags)
              type = solv_chksum_str2type(checksumtype);
              if (!type)
                {
-                 fprintf(stderr, "Unknown checksum type: %s: %s\n", value, checksumtype);
+                 pool_error(pool, -1, "%s: unknown checksum type '%s'", value, checksumtype);
+                 res = 1;
                  continue;
                }
               l = solv_chksum_len(type);
              if (strlen(checksum) != 2 * l)
                {
-                 fprintf(stderr, "Invalid checksum length: %s: for %s\n", value, checksum);
+                 pool_error(pool, -1, "%s: invalid checksum length for %s", value, checksumtype);
+                 res = 1;
                  continue;
                }
              fh = repodata_new_handle(data);
@@ -403,11 +407,11 @@ repo_add_content(Repo *repo, FILE *fp, int flags)
            }
 
          if (istag ("VERSION"))
-            pd.tmpvers = strdup(value);
+            pd.tmpvers = solv_strdup(value);
           else if (istag ("RELEASE"))
-            pd.tmprel = strdup(value);
+            pd.tmprel = solv_strdup(value);
          else if (code11 && istag ("DISTRIBUTION"))
-           repodata_set_str(data, s - pool->solvables, SOLVABLE_DISTRIBUTION, value);
+           repodata_set_poolstr(data, s - pool->solvables, SOLVABLE_DISTRIBUTION, value);
          else if (istag ("UPDATEURLS"))
            add_multiple_urls(data, handle, value, pool_str2id(pool, "update", 1));
          else if (istag ("EXTRAURLS"))
@@ -498,7 +502,7 @@ repo_add_content(Repo *repo, FILE *fp, int flags)
   if (s && !s->name)
     {
       pool_debug(pool, SOLV_FATAL, "repo_content: 'content' incomplete, no product solvable created!\n");
-      repo_free_solvable_block(repo, s - pool->solvables, 1, 1);
+      repo_free_solvable(repo, s - pool->solvables, 1);
       s = 0;
     }
   if (s)
@@ -542,8 +546,7 @@ repo_add_content(Repo *repo, FILE *fp, int flags)
     solv_free(pd.tmp);
   solv_free(line);
   solv_free(otherarchs);
-  join_freemem();
   if (!(flags & REPO_NO_INTERNALIZE))
     repodata_internalize(data);
-  return 0;
+  return res;
 }