Imported Upstream version 0.7.20
[platform/upstream/libsolv.git] / src / repo_write.c
index d3b8a83..af4e759 100644 (file)
@@ -187,16 +187,6 @@ write_id(Repodata *data, Id x)
 }
 
 static inline void
-write_id_eof(Repodata *data, Id x, int eof)
-{
-  if (x >= 64)
-    x = (x & 63) | ((x & ~63) << 1);
-  write_id(data, x | (eof ? 0 : 64));
-}
-
-
-
-static inline void
 write_str(Repodata *data, const char *str)
 {
   if (data->error)
@@ -580,25 +570,29 @@ collect_needed_cb(void *vcbdata, Solvable *s, Repodata *data, Repokey *key, KeyV
        break;
       case REPOKEY_TYPE_FIXARRAY:
       case REPOKEY_TYPE_FLEXARRAY:
-       if (kv->entry == 0)
+       if (kv->entry)
          {
-           if (kv->eof != 2)
-             *cbdata->sp++ = 0;        /* mark start */
-         }
-       else
-         {
-           /* just finished a schema, rewind to start */
+           /* finish schema, rewind to start */
            Id *sp = cbdata->sp - 1;
            *sp = 0;
            while (sp[-1])
              sp--;
-           if (kv->entry == 1 || key->type == REPOKEY_TYPE_FLEXARRAY)
+           if (sp[-2] >= 0)
+             cbdata->subschemata[sp[-2]] = repodata_schema2id(cbdata->target, sp, 1);
+           cbdata->sp = sp - 2;
+         }
+       if (kv->eof != 2)
+         {
+           /* start new schema */
+           if (kv->entry == 0 || key->type == REPOKEY_TYPE_FLEXARRAY)
              {
                cbdata->subschemata = solv_extend(cbdata->subschemata, cbdata->nsubschemata, 1, sizeof(Id), SCHEMATA_BLOCK);
-               cbdata->subschemata[cbdata->nsubschemata++] = repodata_schema2id(cbdata->target, sp, 1);
+               *cbdata->sp++ = cbdata->nsubschemata++;
              }
-           cbdata->sp = kv->eof == 2 ? sp - 1: sp;
-         }
+           else
+             *cbdata->sp++ = -1;
+           *cbdata->sp++ = 0;
+          }
        break;
       default:
        break;
@@ -1452,7 +1446,7 @@ for (i = 1; i < target.nkeys; i++)
       reloff += 3 * target.nkeys;
     }
 
-  needid = calloc(reloff + pool->nrels, sizeof(*needid));
+  needid = solv_calloc(reloff + pool->nrels, sizeof(*needid));
   needid[0].map = reloff;      /* remember size in case we need to grow */
 
   cbdata.needid = needid;