+incore_add_sizek(Repodata *data, unsigned int sx)
+{
+ if (sx < (1 << 22))
+ incore_add_id(data, (Id)(sx << 10));
+ else
+ {
+ if ((sx >> 25) != 0)
+ {
+ incore_add_id(data, (Id)(sx >> 25));
+ data->incoredata[data->incoredatalen - 1] |= 128;
+ }
+ incore_add_id(data, (Id)((sx << 10) | 0x80000000));
+ data->incoredata[data->incoredatalen - 5] = (sx >> 18) | 128;
+ }
+}
+
+static void
+incore_add_ideof(Repodata *data, Id sx, int eof)
+{
+ unsigned int x = (unsigned int)sx;
+ unsigned char *dp;
+ /* make sure we have at least 5 bytes free */
+ if (data->incoredatafree < 5)
+ {
+ data->incoredata = solv_realloc(data->incoredata, data->incoredatalen + INCORE_ADD_CHUNK);
+ data->incoredatafree = INCORE_ADD_CHUNK;
+ }
+ dp = data->incoredata + data->incoredatalen;
+ if (x >= (1 << 13))
+ {
+ if (x >= (1 << 27))
+ *dp++ = (x >> 27) | 128;
+ if (x >= (1 << 20))
+ *dp++ = (x >> 20) | 128;
+ *dp++ = (x >> 13) | 128;
+ }
+ if (x >= (1 << 6))
+ *dp++ = (x >> 6) | 128;
+ *dp++ = eof ? (x & 63) : (x & 63) | 64;
+ data->incoredatafree -= dp - (data->incoredata + data->incoredatalen);
+ data->incoredatalen = dp - data->incoredata;
+}
+
+static void
+incore_add_blob(Repodata *data, unsigned char *buf, int len)
+{
+ if (data->incoredatafree < (unsigned int)len)
+ {
+ data->incoredata = solv_realloc(data->incoredata, data->incoredatalen + INCORE_ADD_CHUNK + len);
+ data->incoredatafree = INCORE_ADD_CHUNK + len;
+ }
+ memcpy(data->incoredata + data->incoredatalen, buf, len);
+ data->incoredatafree -= len;
+ data->incoredatalen += len;
+}
+
+static void
+incore_map_idarray(Repodata *data, unsigned char *dp, Id *map, Id max)
+{
+ /* We have to map the IDs, which might also change
+ the necessary number of bytes, so we can't just copy
+ over the blob and adjust it. */
+ for (;;)
+ {
+ Id id;
+ int eof;
+ dp = data_read_ideof(dp, &id, &eof);
+ if (id < 0 || (max && id >= max))
+ {
+ data->error = pool_error(data->repo->pool, SOLV_ERROR_ID_RANGE, "incore_map_idarray: id too large (%u/%u)", id, max);
+ break;
+ }
+ id = map[id];
+ incore_add_ideof(data, id, eof);
+ if (eof)
+ break;
+ }
+}
+
+#if 0
+static void