optimize string handling in repo_add_solv a bit
[platform/upstream/libsolv.git] / src / repo_solv.c
1 /*
2  * Copyright (c) 2007, Novell Inc.
3  *
4  * This program is licensed under the BSD license, read LICENSE.BSD
5  * for further information
6  */
7
8 /*
9  * repo_solv.c
10  * 
11  * Add a repo in solv format
12  * 
13  */
14
15
16
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <unistd.h>
20 #include <string.h>
21
22 #include "repo_solv.h"
23 #include "util.h"
24
25 #include "repopack.h"
26 #include "repopage.h"
27
28 #include "poolid_private.h"     /* WHATPROVIDES_BLOCK */
29
30 #define INTERESTED_START        SOLVABLE_NAME
31 #define INTERESTED_END          SOLVABLE_ENHANCES
32
33 #define SOLV_ERROR_NOT_SOLV     1
34 #define SOLV_ERROR_UNSUPPORTED  2
35 #define SOLV_ERROR_EOF          3
36 #define SOLV_ERROR_ID_RANGE     4
37 #define SOLV_ERROR_OVERFLOW     5
38 #define SOLV_ERROR_CORRUPT      6
39
40
41
42 /*******************************************************************************
43  * functions to extract data from a file handle
44  */
45
46 /*
47  * read u32
48  */
49
50 static unsigned int
51 read_u32(Repodata *data)
52 {
53   int c, i;
54   unsigned int x = 0;
55
56   if (data->error)
57     return 0;
58   for (i = 0; i < 4; i++)
59     {
60       c = getc(data->fp);
61       if (c == EOF)
62         {
63           data->error = pool_error(data->repo->pool, SOLV_ERROR_EOF, "unexpected EOF");
64           return 0;
65         }
66       x = (x << 8) | c;
67     }
68   return x;
69 }
70
71
72 /*
73  * read u8
74  */
75
76 static unsigned int
77 read_u8(Repodata *data)
78 {
79   int c;
80
81   if (data->error)
82     return 0;
83   c = getc(data->fp);
84   if (c == EOF)
85     {
86       data->error = pool_error(data->repo->pool, SOLV_ERROR_EOF, "unexpected EOF");
87       return 0;
88     }
89   return c;
90 }
91
92
93 /*
94  * read Id
95  */
96
97 static Id
98 read_id(Repodata *data, Id max)
99 {
100   unsigned int x = 0;
101   int c, i;
102
103   if (data->error)
104     return 0;
105   for (i = 0; i < 5; i++)
106     {
107       c = getc(data->fp);
108       if (c == EOF)
109         {
110           data->error = pool_error(data->repo->pool, SOLV_ERROR_EOF, "unexpected EOF");
111           return 0;
112         }
113       if (!(c & 128))
114         {
115           x = (x << 7) | c;
116           if (max && x >= max)
117             {
118               data->error = pool_error(data->repo->pool, SOLV_ERROR_ID_RANGE, "read_id: id too large (%u/%u)", x, max);
119               return 0;
120             }
121           return x;
122         }
123       x = (x << 7) ^ c ^ 128;
124     }
125   data->error = pool_error(data->repo->pool, SOLV_ERROR_CORRUPT, "read_id: id too long");
126   return 0;
127 }
128
129
130 static Id *
131 read_idarray(Repodata *data, Id max, Id *map, Id *store, Id *end)
132 {
133   unsigned int x = 0;
134   int c;
135
136   if (data->error)
137     return 0;
138   for (;;)
139     {
140       c = getc(data->fp);
141       if (c == EOF)
142         {
143           data->error = pool_error(data->repo->pool, SOLV_ERROR_EOF, "unexpected EOF");
144           return 0;
145         }
146       if ((c & 128) != 0)
147         {
148           x = (x << 7) ^ c ^ 128;
149           continue;
150         }
151       x = (x << 6) | (c & 63);
152       if (max && x >= max)
153         {
154           data->error = pool_error(data->repo->pool, SOLV_ERROR_ID_RANGE, "read_idarray: id too large (%u/%u)", x, max);
155           return 0;
156         }
157       if (map)
158         x = map[x];
159       if (store == end)
160         {
161           data->error = pool_error(data->repo->pool, SOLV_ERROR_OVERFLOW, "read_idarray: array overflow");
162           return 0;
163         }
164       *store++ = x;
165       if ((c & 64) == 0)
166         {
167           if (x == 0)   /* already have trailing zero? */
168             return store;
169           if (store == end)
170             {
171               data->error = pool_error(data->repo->pool, SOLV_ERROR_OVERFLOW, "read_idarray: array overflow");
172               return 0;
173             }
174           *store++ = 0;
175           return store;
176         }
177       x = 0;
178     }
179 }
180
181
182 /*******************************************************************************
183  * functions to extract data from memory
184  */
185
186 /*
187  * read array of Ids
188  */
189
190 static inline unsigned char *
191 data_read_id_max(unsigned char *dp, Id *ret, Id *map, int max, Repodata *data)
192 {
193   Id x;
194   dp = data_read_id(dp, &x);
195   if (x < 0 || (max && x >= max))
196     {
197       data->error = pool_error(data->repo->pool, SOLV_ERROR_ID_RANGE, "data_read_id_max: id too large (%u/%u)", x, max);
198       x = 0;
199     }
200   *ret = map ? map[x] : x;
201   return dp;
202 }
203
204 static unsigned char *
205 data_read_idarray(unsigned char *dp, Id **storep, Id *map, int max, Repodata *data)
206 {
207   Id *store = *storep;
208   unsigned int x = 0;
209   int c;
210
211   for (;;)
212     {
213       c = *dp++;
214       if ((c & 128) != 0)
215         {
216           x = (x << 7) ^ c ^ 128;
217           continue;
218         }
219       x = (x << 6) | (c & 63);
220       if (max && x >= max)
221         {
222           data->error = pool_error(data->repo->pool, SOLV_ERROR_ID_RANGE, "data_read_idarray: id too large (%u/%u)", x, max);
223           data->error = SOLV_ERROR_ID_RANGE;
224           break;
225         }
226       *store++ = x;
227       if ((c & 64) == 0)
228         break;
229       x = 0;
230     }
231   *store++ = 0;
232   *storep = store;
233   return dp;
234 }
235
236 static unsigned char *
237 data_read_rel_idarray(unsigned char *dp, Id **storep, Id *map, int max, Repodata *data, Id marker)
238 {
239   Id *store = *storep;
240   Id old = 0;
241   unsigned int x = 0;
242   int c;
243
244   for (;;)
245     {
246       c = *dp++;
247       if ((c & 128) != 0)
248         {
249           x = (x << 7) ^ c ^ 128;
250           continue;
251         }
252       x = (x << 6) | (c & 63);
253       if (x == 0)
254         {
255           if (!(c & 64))
256             break;
257           if (marker)
258             *store++ = marker;
259           old = 0;
260           continue;
261         }
262       x = old + (x - 1);
263       old = x;
264       if (max && x >= max)
265         {
266           data->error = pool_error(data->repo->pool, SOLV_ERROR_ID_RANGE, "data_read_rel_idarray: id too large (%u/%u)", x, max);
267           break;
268         }
269       *store++ = map ? map[x] : x;
270       if (!(c & 64))
271         break;
272       x = 0;
273     }
274   *store++ = 0;
275   *storep = store;
276   return dp;
277 }
278
279
280
281
282 /*******************************************************************************
283  * functions to add data to our incore memory space
284  */
285
286 #define INCORE_ADD_CHUNK 8192
287 #define DATA_READ_CHUNK 8192
288
289 static void
290 incore_add_id(Repodata *data, Id sx)
291 {
292   unsigned int x = (unsigned int)sx;
293   unsigned char *dp;
294   /* make sure we have at least 5 bytes free */
295   if (data->incoredatafree < 5)
296     {
297       data->incoredata = solv_realloc(data->incoredata, data->incoredatalen + INCORE_ADD_CHUNK);
298       data->incoredatafree = INCORE_ADD_CHUNK;
299     }
300   dp = data->incoredata + data->incoredatalen;
301   if (x >= (1 << 14))
302     {
303       if (x >= (1 << 28))
304         *dp++ = (x >> 28) | 128;
305       if (x >= (1 << 21))
306         *dp++ = (x >> 21) | 128;
307       *dp++ = (x >> 14) | 128;
308     }
309   if (x >= (1 << 7))
310     *dp++ = (x >> 7) | 128;
311   *dp++ = x & 127;
312   data->incoredatafree -= dp - (data->incoredata + data->incoredatalen);
313   data->incoredatalen = dp - data->incoredata;
314 }
315
316 static void
317 incore_add_sizek(Repodata *data, unsigned int sx)
318 {
319   if (sx < (1 << 22))
320     incore_add_id(data, (Id)(sx << 10));
321   else
322     {
323       if ((sx >> 25) != 0)
324         {
325           incore_add_id(data, (Id)(sx >> 25));
326           data->incoredata[data->incoredatalen - 1] |= 128;
327         }
328       incore_add_id(data, (Id)((sx << 10) | 0x80000000));
329       data->incoredata[data->incoredatalen - 5] = (sx >> 18) | 128;
330     }
331 }
332
333 static void
334 incore_add_ideof(Repodata *data, Id sx, int eof)
335 {
336   unsigned int x = (unsigned int)sx;
337   unsigned char *dp;
338   /* make sure we have at least 5 bytes free */
339   if (data->incoredatafree < 5)
340     {
341       data->incoredata = solv_realloc(data->incoredata, data->incoredatalen + INCORE_ADD_CHUNK);
342       data->incoredatafree = INCORE_ADD_CHUNK;
343     }
344   dp = data->incoredata + data->incoredatalen;
345   if (x >= (1 << 13))
346     {
347       if (x >= (1 << 27))
348         *dp++ = (x >> 27) | 128;
349       if (x >= (1 << 20))
350         *dp++ = (x >> 20) | 128;
351       *dp++ = (x >> 13) | 128;
352     }
353   if (x >= (1 << 6))
354     *dp++ = (x >> 6) | 128;
355   *dp++ = eof ? (x & 63) : (x & 63) | 64;
356   data->incoredatafree -= dp - (data->incoredata + data->incoredatalen);
357   data->incoredatalen = dp - data->incoredata;
358 }
359
360 static void
361 incore_add_blob(Repodata *data, unsigned char *buf, int len)
362 {
363   if (data->incoredatafree < len)
364     {
365       data->incoredata = solv_realloc(data->incoredata, data->incoredatalen + INCORE_ADD_CHUNK + len);
366       data->incoredatafree = INCORE_ADD_CHUNK + len;
367     }
368   memcpy(data->incoredata + data->incoredatalen, buf, len);
369   data->incoredatafree -= len;
370   data->incoredatalen += len;
371 }
372
373 static void
374 incore_map_idarray(Repodata *data, unsigned char *dp, Id *map, Id max)
375 {
376   /* We have to map the IDs, which might also change
377      the necessary number of bytes, so we can't just copy
378      over the blob and adjust it.  */
379   for (;;)
380     {
381       Id id;
382       int eof;
383       dp = data_read_ideof(dp, &id, &eof);
384       if (id < 0 || (max && id >= max))
385         {
386           data->error = pool_error(data->repo->pool, SOLV_ERROR_ID_RANGE, "incore_map_idarray: id too large (%u/%u)", id, max);
387           break;
388         }
389       id = map[id];
390       incore_add_ideof(data, id, eof);
391       if (eof)
392         break;
393     }
394 }
395
396 #if 0
397 static void
398 incore_add_u32(Repodata *data, unsigned int x)
399 {
400   unsigned char *dp;
401   /* make sure we have at least 4 bytes free */
402   if (data->incoredatafree < 4)
403     {
404       data->incoredata = solv_realloc(data->incoredata, data->incoredatalen + INCORE_ADD_CHUNK);
405       data->incoredatafree = INCORE_ADD_CHUNK;
406     }
407   dp = data->incoredata + data->incoredatalen;
408   *dp++ = x >> 24;
409   *dp++ = x >> 16;
410   *dp++ = x >> 8;
411   *dp++ = x;
412   data->incoredatafree -= 4;
413   data->incoredatalen += 4;
414 }
415
416 static void
417 incore_add_u8(Repodata *data, unsigned int x)
418 {
419   unsigned char *dp;
420   /* make sure we have at least 1 byte free */
421   if (data->incoredatafree < 1)
422     {
423       data->incoredata = solv_realloc(data->incoredata, data->incoredatalen + 1024);
424       data->incoredatafree = 1024;
425     }
426   dp = data->incoredata + data->incoredatalen;
427   *dp++ = x;
428   data->incoredatafree--;
429   data->incoredatalen++;
430 }
431 #endif
432
433
434 /*******************************************************************************
435  * our main function
436  */
437
438 /*
439  * read repo from .solv file and add it to pool
440  */
441
442 int
443 repo_add_solv(Repo *repo, FILE *fp, int flags)
444 {
445   Pool *pool = repo->pool;
446   int i, l;
447   unsigned int numid, numrel, numdir, numsolv;
448   unsigned int numkeys, numschemata;
449
450   Offset sizeid;
451   Offset *str;                         /* map Id -> Offset into string space */
452   char *strsp;                         /* repo string space */
453   char *sp;                            /* pointer into string space */
454   Id *idmap;                           /* map of repo Ids to pool Ids */
455   Id id, type;
456   unsigned int hashmask, h;
457   int hh;
458   Id *hashtbl;
459   Id name, evr, did;
460   int relflags;
461   Reldep *ran;
462   unsigned int size_idarray;
463   Id *idarraydatap, *idarraydataend;
464   Offset ido;
465   Solvable *s;
466   unsigned int solvflags;
467   unsigned int solvversion;
468   Repokey *keys;
469   Id *schemadata, *schemadatap, *schemadataend;
470   Id *schemata, key, *keyp;
471   int nentries;
472   int have_incoredata;
473   int maxsize, allsize;
474   unsigned char *buf, *bufend, *dp, *dps;
475   Id stack[3 * 5];
476   int keydepth;
477   int needchunk;        /* need a new chunk of data */
478   unsigned int now;
479   int oldnstrings = pool->ss.nstrings;
480   int oldnrels = pool->nrels;
481
482   struct _Stringpool *spool;
483
484   Repodata *parent = 0;
485   Repodata data;
486
487   int extendstart = 0, extendend = 0;   /* set in case we're extending */
488
489   now = solv_timems(0);
490
491   if ((flags & REPO_USE_LOADING) != 0)
492     {
493       /* this is a stub replace operation */
494       flags |= REPO_EXTEND_SOLVABLES;
495       /* use REPO_REUSE_REPODATA hack so that the old repodata is kept */
496       parent = repo_add_repodata(repo, flags | REPO_REUSE_REPODATA);
497       extendstart = parent->start;
498       extendend = parent->end;
499     }
500   else if (flags & REPO_EXTEND_SOLVABLES)
501     {
502       /* extend all solvables of this repo */
503       extendstart = repo->start;
504       extendend = repo->end;
505     }
506     
507   memset(&data, 0, sizeof(data));
508   data.repo = repo;
509   data.fp = fp;
510   repopagestore_init(&data.store);
511
512   if (read_u32(&data) != ('S' << 24 | 'O' << 16 | 'L' << 8 | 'V'))
513      return pool_error(pool, SOLV_ERROR_NOT_SOLV, "not a SOLV file");
514   solvversion = read_u32(&data);
515   switch (solvversion)
516     {
517       case SOLV_VERSION_8:
518         break;
519       default:
520         return pool_error(pool, SOLV_ERROR_UNSUPPORTED, "unsupported SOLV version");
521     }
522
523   numid = read_u32(&data);
524   numrel = read_u32(&data);
525   numdir = read_u32(&data);
526   numsolv = read_u32(&data);
527   numkeys = read_u32(&data);
528   numschemata = read_u32(&data);
529   solvflags = read_u32(&data);
530
531   if (numdir && numdir < 2)
532     return pool_error(pool, SOLV_ERROR_CORRUPT, "bad number of dirs");
533
534   if (numrel && (flags & REPO_LOCALPOOL) != 0)
535     return pool_error(pool, SOLV_ERROR_CORRUPT, "relations are forbidden in a local pool");
536   if ((flags & REPO_EXTEND_SOLVABLES) && numsolv)
537     {
538       /* make sure that we exactly replace the stub repodata */
539       if (extendend - extendstart != numsolv)
540         return pool_error(pool, SOLV_ERROR_CORRUPT, "sub-repository solvable number does not match main repository (%d - %d)", extendend - extendstart, numsolv);
541       for (i = 0; i < numsolv; i++)
542         if (pool->solvables[extendstart + i].repo != repo)
543           return pool_error(pool, SOLV_ERROR_CORRUPT, "main repository contains holes, cannot extend");
544     }
545
546   /*******  Part 1: string IDs  *****************************************/
547
548   sizeid = read_u32(&data);            /* size of string space */
549
550   /*
551    * read strings and Ids
552    * 
553    */
554
555   
556   /*
557    * alloc buffers
558    */
559
560   if (!(flags & REPO_LOCALPOOL))
561     {
562       spool = &pool->ss;
563       /* alloc max needed string buffer and string pointers, will shrink again later */
564 #if 0
565       spool->stringspace = solv_realloc(spool->stringspace, spool->sstrings + sizeid + 1); 
566       spool->strings = solv_realloc2(spool->strings, spool->nstrings + numid, sizeof(Offset));
567 #else
568       spool->sstrings += sizeid + 1;
569       spool->nstrings += numid;
570       stringpool_shrink(spool);         /* we misuse stringpool_shrink so that the correct BLOCK factor is used */
571       spool->sstrings -= sizeid + 1;
572       spool->nstrings -= numid;
573 #endif
574     }
575   else
576     {
577       data.localpool = 1;
578       spool = &data.spool;
579       spool->sstrings = 7 + sizeid + 1;
580       spool->nstrings = numid < 2 ? 2 : numid;
581       stringpool_shrink(spool);         /* we misuse stringpool_shrink to alloc the stringpool in the correct size */
582       strcpy(spool->stringspace, "<NULL>");
583       spool->sstrings = 7;
584       spool->nstrings = 1;
585       spool->strings[0] = 0;    /* <NULL> */
586     }
587
588
589   /*
590    * read string data and append to old string space
591    */
592   
593   strsp = spool->stringspace + spool->sstrings; /* append new entries */
594   if ((solvflags & SOLV_FLAG_PREFIX_POOL) == 0)
595     {
596       if (sizeid && fread(strsp, sizeid, 1, fp) != 1)
597         return pool_error(pool, SOLV_ERROR_EOF, "read error while reading strings");
598     }
599   else
600     {
601       unsigned int pfsize = read_u32(&data);
602       char *prefix = solv_malloc(pfsize);
603       char *pp = prefix;
604       char *old_str = 0;
605       char *dest = strsp;
606       int freesp = sizeid;
607
608       if (pfsize && fread(prefix, pfsize, 1, fp) != 1)
609         {
610           solv_free(prefix);
611           return pool_error(pool, SOLV_ERROR_EOF, "read error while reading strings");
612         }
613       for (i = 1; i < numid; i++)
614         {
615           int same = (unsigned char)*pp++;
616           size_t len = strlen(pp) + 1;
617           freesp -= same + len;
618           if (freesp < 0)
619             {
620               solv_free(prefix);
621               return pool_error(pool, SOLV_ERROR_OVERFLOW, "overflow while expanding strings");
622             }
623           if (same)
624             memcpy(dest, old_str, same);
625           memcpy(dest + same, pp, len);
626           pp += len;
627           old_str = dest;
628           dest += same + len;
629         }
630       solv_free(prefix);
631       if (freesp != 0)
632         return pool_error(pool, SOLV_ERROR_CORRUPT, "expanding strings size mismatch");
633     }
634   strsp[sizeid] = 0;                   /* make string space \0 terminated */
635   sp = strsp;
636
637   /* now merge */
638   str = spool->strings;                 /* array of offsets into strsp, indexed by Id */
639   if ((flags & REPO_LOCALPOOL) != 0)
640     {
641       /* no shared pool, thus no idmap and no unification needed */
642       idmap = 0;
643       spool->nstrings = numid < 2 ? 2 : numid;  /* make sure we have at least id 0 and 1 */
644       if (*sp)
645         {
646           /* we need id 1 to be '' for directories */
647           return pool_error(pool, SOLV_ERROR_CORRUPT, "store strings don't start with an empty string");
648         }
649       for (i = 1; i < spool->nstrings; i++)
650         {
651           if (sp >= strsp + sizeid && numid >= 2)
652             return pool_error(pool, SOLV_ERROR_OVERFLOW, "not enough strings");
653           str[i] = sp - spool->stringspace;
654           sp += strlen(sp) + 1;
655         }
656       spool->sstrings = sp - spool->stringspace;
657     }
658   else
659     {
660       /* alloc id map for name and rel Ids. this maps ids in the solv files
661        * to the ids in our pool */
662       idmap = solv_calloc(numid + numrel, sizeof(Id));
663
664       /* grow hash if needed, otherwise reuse */
665       hashmask = mkmask(spool->nstrings + numid);
666 #if 0
667       POOL_DEBUG(SOLV_DEBUG_STATS, "read %d strings\n", numid);
668       POOL_DEBUG(SOLV_DEBUG_STATS, "string hash buckets: %d, old %d\n", hashmask + 1, spool->stringhashmask + 1);
669 #endif
670       if (hashmask > spool->stringhashmask)
671         {
672           spool->stringhashtbl = solv_free(spool->stringhashtbl);
673           spool->stringhashmask = hashmask;
674           spool->stringhashtbl = hashtbl = solv_calloc(hashmask + 1, sizeof(Id));
675           for (i = 1; i < spool->nstrings; i++)
676             {
677               h = strhash(spool->stringspace + spool->strings[i]) & hashmask;
678               hh = HASHCHAIN_START;
679               while (hashtbl[h])
680                 h = HASHCHAIN_NEXT(h, hh, hashmask);
681               hashtbl[h] = i;
682             }
683         }
684       else
685         {
686           hashtbl = spool->stringhashtbl;
687           hashmask = spool->stringhashmask;
688         }
689
690       /*
691        * run over strings and merge with pool.
692        * also populate id map (maps solv Id -> pool Id)
693        */
694       for (i = 1; i < numid; i++)
695         {
696           if (sp >= strsp + sizeid)
697             {
698               solv_free(hashtbl);
699               solv_free(idmap);
700               return pool_error(pool, SOLV_ERROR_OVERFLOW, "not enough strings %d %d", i, numid);
701             }
702           if (!*sp)                            /* empty string */
703             {
704               idmap[i] = ID_EMPTY;
705               sp++;
706               continue;
707             }
708
709           /* find hash slot */
710           h = strhash(sp) & hashmask;
711           hh = HASHCHAIN_START;
712           for (;;)
713             {
714               id = hashtbl[h];
715               if (!id)
716                 break;
717               if (!strcmp(spool->stringspace + spool->strings[id], sp))
718                 break;          /* already in pool */
719               h = HASHCHAIN_NEXT(h, hh, hashmask);
720             }
721
722           /* length == offset to next string */
723           l = strlen(sp) + 1;
724           if (!id)             /* end of hash chain -> new string */
725             {
726               id = spool->nstrings++;
727               hashtbl[h] = id;
728               str[id] = spool->sstrings;        /* save offset */
729               if (sp != spool->stringspace + spool->sstrings)
730                 memmove(spool->stringspace + spool->sstrings, sp, l);
731               spool->sstrings += l;
732             }
733           idmap[i] = id;       /* repo relative -> pool relative */
734           sp += l;             /* next string */
735         }
736       if (hashmask > mkmask(spool->nstrings + 8192))
737         {
738           spool->stringhashtbl = solv_free(spool->stringhashtbl);
739           spool->stringhashmask = 0;
740         }
741       stringpool_shrink(spool);         /* vacuum */
742     }
743
744   
745   /*******  Part 2: Relation IDs  ***************************************/
746
747   /*
748    * read RelDeps
749    * 
750    */
751   
752   if (numrel)
753     {
754       /* extend rels */
755       pool->rels = solv_realloc2(pool->rels, pool->nrels + numrel, sizeof(Reldep));
756       ran = pool->rels;
757
758       /* grow hash if needed, otherwise reuse */
759       hashmask = mkmask(pool->nrels + numrel);
760 #if 0
761       POOL_DEBUG(SOLV_DEBUG_STATS, "read %d rels\n", numrel);
762       POOL_DEBUG(SOLV_DEBUG_STATS, "rel hash buckets: %d, old %d\n", hashmask + 1, pool->relhashmask + 1);
763 #endif
764       if (hashmask > pool->relhashmask)
765         {
766           pool->relhashtbl = solv_free(pool->relhashtbl);
767           pool->relhashmask = hashmask;
768           pool->relhashtbl = hashtbl = solv_calloc(hashmask + 1, sizeof(Id));
769           for (i = 1; i < pool->nrels; i++)
770             {
771               h = relhash(ran[i].name, ran[i].evr, ran[i].flags) & hashmask;
772               hh = HASHCHAIN_START;
773               while (hashtbl[h])
774                 h = HASHCHAIN_NEXT(h, hh, hashmask);
775               hashtbl[h] = i;
776             }
777         }
778       else
779         {
780           hashtbl = pool->relhashtbl;
781           hashmask = pool->relhashmask;
782         }
783
784       /*
785        * read RelDeps from repo
786        */
787       for (i = 0; i < numrel; i++)
788         {
789           name = read_id(&data, i + numid);     /* read (repo relative) Ids */
790           evr = read_id(&data, i + numid);
791           relflags = read_u8(&data);
792           name = idmap[name];           /* map to (pool relative) Ids */
793           evr = idmap[evr];
794           h = relhash(name, evr, relflags) & hashmask;
795           hh = HASHCHAIN_START;
796           for (;;)
797             {
798               id = hashtbl[h];
799               if (!id)          /* end of hash chain reached */
800                 break;
801               if (ran[id].name == name && ran[id].evr == evr && ran[id].flags == relflags)
802                 break;
803               h = HASHCHAIN_NEXT(h, hh, hashmask);
804             }
805           if (!id)              /* new RelDep */
806             {
807               id = pool->nrels++;
808               hashtbl[h] = id;
809               ran[id].name = name;
810               ran[id].evr = evr;
811               ran[id].flags = relflags;
812             }
813           idmap[i + numid] = MAKERELDEP(id);   /* fill Id map */
814         }
815       if (hashmask > mkmask(pool->nrels + 4096))
816         {
817           pool->relhashtbl = solv_free(pool->relhashtbl);
818           pool->relhashmask = 0;
819         }
820       pool_shrink_rels(pool);           /* vacuum */
821     }
822
823   /* if we added ids/rels, make room in our whatprovide arrays */
824   if (!(flags & REPO_LOCALPOOL))
825     {
826       if (pool->whatprovides && oldnstrings != pool->ss.nstrings)
827         {
828           int newlen = (pool->ss.nstrings + WHATPROVIDES_BLOCK) & ~WHATPROVIDES_BLOCK;
829           pool->whatprovides = solv_realloc2(pool->whatprovides, newlen, sizeof(Offset));
830           memset(pool->whatprovides + oldnstrings, 0, (newlen - oldnstrings) * sizeof(Offset));
831         }
832       if (pool->whatprovides_rel && oldnrels != pool->nrels)
833         {
834           int newlen = (pool->nrels + WHATPROVIDES_BLOCK) & ~WHATPROVIDES_BLOCK;
835           pool->whatprovides_rel = solv_realloc2(pool->whatprovides_rel, newlen, sizeof(Offset));
836           memset(pool->whatprovides_rel + oldnrels, 0, (newlen - oldnrels) * sizeof(Offset));
837         }
838     }
839
840   /*******  Part 3: Dirs  ***********************************************/
841   if (numdir)
842     {
843       data.dirpool.dirs = solv_malloc2(numdir, sizeof(Id));
844       data.dirpool.ndirs = numdir;
845       data.dirpool.dirs[0] = 0;         /* dir 0: virtual root */
846       data.dirpool.dirs[1] = 1;         /* dir 1: / */
847       for (i = 2; i < numdir; i++)
848         {
849           id = read_id(&data, i + numid);
850           if (id >= numid)
851             data.dirpool.dirs[i] = -(id - numid);
852           else if (idmap)
853             data.dirpool.dirs[i] = idmap[id];
854           else
855             data.dirpool.dirs[i] = id;
856         }
857     }
858
859   /*******  Part 4: Keys  ***********************************************/
860
861   keys = solv_calloc(numkeys, sizeof(*keys));
862   /* keys start at 1 */
863   for (i = 1; i < numkeys; i++)
864     {
865       id = read_id(&data, numid);
866       if (idmap)
867         id = idmap[id];
868       else if ((flags & REPO_LOCALPOOL) != 0)
869         id = pool_str2id(pool, stringpool_id2str(spool, id), 1);
870       type = read_id(&data, numid);
871       if (idmap)
872         type = idmap[type];
873       else if ((flags & REPO_LOCALPOOL) != 0)
874         type = pool_str2id(pool, stringpool_id2str(spool, type), 1);
875       if (type < REPOKEY_TYPE_VOID || type > REPOKEY_TYPE_FLEXARRAY)
876         {
877           data.error = pool_error(pool, SOLV_ERROR_UNSUPPORTED, "unsupported data type '%s'", pool_id2str(pool, type));
878           type = REPOKEY_TYPE_VOID;
879         }
880       keys[i].name = id;
881       keys[i].type = type;
882       keys[i].size = read_id(&data, keys[i].type == REPOKEY_TYPE_CONSTANTID ? numid + numrel : 0);
883       keys[i].storage = read_id(&data, 0);
884       /* old versions used SOLVABLE for main solvable data */
885       if (keys[i].storage == KEY_STORAGE_SOLVABLE)
886         keys[i].storage = KEY_STORAGE_INCORE;
887       if (keys[i].storage != KEY_STORAGE_INCORE && keys[i].storage != KEY_STORAGE_VERTICAL_OFFSET)
888         data.error = pool_error(pool, SOLV_ERROR_UNSUPPORTED, "unsupported storage type %d", keys[i].storage);
889       if (id >= SOLVABLE_NAME && id <= RPM_RPMDBID)
890         {
891           if (keys[i].storage != KEY_STORAGE_INCORE)
892             data.error = pool_error(pool, SOLV_ERROR_UNSUPPORTED, "main solvable data must use incore storage %d", keys[i].storage);
893           keys[i].storage = KEY_STORAGE_SOLVABLE;
894         }
895       /* cannot handle rel idarrays in incore/vertical */
896       if (type == REPOKEY_TYPE_REL_IDARRAY && keys[i].storage != KEY_STORAGE_SOLVABLE)
897         data.error = pool_error(pool, SOLV_ERROR_UNSUPPORTED, "type REL_IDARRAY is only supported for STORAGE_SOLVABLE");
898       /* cannot handle mapped ids in vertical */
899       if (!(flags & REPO_LOCALPOOL) && keys[i].storage == KEY_STORAGE_VERTICAL_OFFSET && (type == REPOKEY_TYPE_ID || type == REPOKEY_TYPE_IDARRAY))
900         data.error = pool_error(pool, SOLV_ERROR_UNSUPPORTED, "mapped ids are not supported for STORAGE_VERTICAL_OFFSET");
901  
902       if (keys[i].type == REPOKEY_TYPE_CONSTANTID && idmap)
903         keys[i].size = idmap[keys[i].size];
904 #if 0
905       fprintf(stderr, "key %d %s %s %d %d\n", i, pool_id2str(pool,id), pool_id2str(pool, keys[i].type),
906                keys[i].size, keys[i].storage);
907 #endif
908     }
909
910   have_incoredata = 0;
911   for (i = 1; i < numkeys; i++)
912     if (keys[i].storage == KEY_STORAGE_INCORE || keys[i].storage == KEY_STORAGE_VERTICAL_OFFSET)
913       have_incoredata = 1;
914
915   data.keys = keys;
916   data.nkeys = numkeys;
917   for (i = 1; i < numkeys; i++)
918     {
919       id = keys[i].name;
920       data.keybits[(id >> 3) & (sizeof(data.keybits) - 1)] |= 1 << (id & 7);
921     }
922
923   /*******  Part 5: Schemata ********************************************/
924   
925   id = read_id(&data, 0);
926   schemadata = solv_calloc(id + 1, sizeof(Id));
927   schemadatap = schemadata + 1;
928   schemadataend = schemadatap + id;
929   schemata = solv_calloc(numschemata, sizeof(Id));
930   for (i = 1; i < numschemata; i++)
931     {
932       schemata[i] = schemadatap - schemadata;
933       schemadatap = read_idarray(&data, numid, 0, schemadatap, schemadataend);
934 #if 0
935       Id *sp = schemadata + schemata[i];
936       fprintf(stderr, "schema %d:", i);
937       for (; *sp; sp++)
938         fprintf(stderr, " %d", *sp);
939       fprintf(stderr, "\n");
940 #endif
941     }
942   data.schemata = schemata;
943   data.nschemata = numschemata;
944   data.schemadata = schemadata;
945   data.schemadatalen = schemadataend - data.schemadata;
946
947   /*******  Part 6: Data ********************************************/
948
949   idarraydatap = idarraydataend = 0;
950   size_idarray = 0;
951
952   maxsize = read_id(&data, 0);
953   allsize = read_id(&data, 0);
954   maxsize += 5; /* so we can read the next schema of an array */
955   if (maxsize > allsize)
956     maxsize = allsize;
957
958   buf = solv_calloc(maxsize + DATA_READ_CHUNK + 4, 1);  /* 4 extra bytes to detect overflows */
959   bufend = buf;
960   dp = buf;
961
962   l = maxsize;
963   if (l < DATA_READ_CHUNK)
964     l = DATA_READ_CHUNK;
965   if (l > allsize)
966     l = allsize;
967   if (!l || fread(buf, l, 1, data.fp) != 1)
968     {
969       data.error = pool_error(pool, SOLV_ERROR_EOF, "unexpected EOF");
970       id = 0;
971     }
972   else
973     {
974       bufend = buf + l;
975       allsize -= l;
976       dp = data_read_id_max(dp, &id, 0, numschemata, &data);
977     }
978
979   incore_add_id(&data, 0);      /* so that incoreoffset 0 means schema 0 */
980   incore_add_id(&data, id);     /* main schema id */
981   keyp = schemadata + schemata[id];
982   data.mainschema = id;
983   for (i = 0; keyp[i]; i++)
984     ;
985   if (i)
986     data.mainschemaoffsets = solv_calloc(i, sizeof(Id));
987
988   nentries = 0;
989   keydepth = 0;
990   s = 0;
991   needchunk = 1;
992   for(;;)
993     {
994       /* make sure we have enough room */
995       if (keydepth == 0 || needchunk)
996         {
997           int left = bufend - dp;
998           /* read data chunk to dp */
999           if (data.error)
1000             break;
1001           if (left < 0)
1002             {
1003               data.error = pool_error(pool, SOLV_ERROR_EOF, "buffer overrun");
1004               break;
1005             }
1006           if (left < maxsize)
1007             {
1008               if (left)
1009                 memmove(buf, dp, left);
1010               l = maxsize - left;
1011               if (l < DATA_READ_CHUNK)
1012                 l = DATA_READ_CHUNK;
1013               if (l > allsize)
1014                 l = allsize;
1015               if (l && fread(buf + left, l, 1, data.fp) != 1)
1016                 {
1017                   data.error = pool_error(pool, SOLV_ERROR_EOF, "unexpected EOF");
1018                   break;
1019                 }
1020               allsize -= l;
1021               left += l;
1022               bufend = buf + left;
1023               if (allsize + left < maxsize)
1024                 maxsize = allsize + left;
1025               dp = buf;
1026             }
1027           needchunk = 0;
1028         }
1029
1030       key = *keyp++;
1031 #if 0
1032 printf("key %d at %d\n", key, (int)(keyp - 1 - schemadata));
1033 #endif
1034       if (!key)
1035         {
1036           if (keydepth <= 3)
1037             needchunk = 1;
1038           if (nentries)
1039             {
1040               if (s && keydepth == 3)
1041                 {
1042                   s++;  /* next solvable */
1043                   if (have_incoredata)
1044                     data.incoreoffset[(s - pool->solvables) - data.start] = data.incoredatalen;
1045                 }
1046               id = stack[keydepth - 1];
1047               if (!id)
1048                 {
1049                   dp = data_read_id_max(dp, &id, 0, numschemata, &data);
1050                   incore_add_id(&data, id);
1051                 }
1052               keyp = schemadata + schemata[id];
1053               nentries--;
1054               continue;
1055             }
1056           if (!keydepth)
1057             break;
1058           --keydepth;
1059           keyp = schemadata + stack[--keydepth];
1060           nentries = stack[--keydepth];
1061 #if 0
1062 printf("pop flexarray %d %d\n", keydepth, nentries);
1063 #endif
1064           if (!keydepth && s)
1065             s = 0;      /* back from solvables */
1066           continue;
1067         }
1068
1069       if (keydepth == 0)
1070         data.mainschemaoffsets[keyp - 1 - (schemadata + schemata[data.mainschema])] = data.incoredatalen;
1071
1072 #if 0
1073 printf("=> %s %s %p\n", pool_id2str(pool, keys[key].name), pool_id2str(pool, keys[key].type), s);
1074 #endif
1075       id = keys[key].name;
1076       if (keys[key].storage == KEY_STORAGE_VERTICAL_OFFSET)
1077         {
1078           dps = dp;
1079           dp = data_skip(dp, REPOKEY_TYPE_ID);
1080           dp = data_skip(dp, REPOKEY_TYPE_ID);
1081           incore_add_blob(&data, dps, dp - dps);        /* just record offset/size */
1082           continue;
1083         }
1084       switch (keys[key].type)
1085         {
1086         case REPOKEY_TYPE_ID:
1087           dp = data_read_id_max(dp, &did, idmap, numid + numrel, &data);
1088           if (s && id == SOLVABLE_NAME)
1089             s->name = did; 
1090           else if (s && id == SOLVABLE_ARCH)
1091             s->arch = did; 
1092           else if (s && id == SOLVABLE_EVR)
1093             s->evr = did; 
1094           else if (s && id == SOLVABLE_VENDOR)
1095             s->vendor = did; 
1096           else if (keys[key].storage == KEY_STORAGE_INCORE)
1097             incore_add_id(&data, did);
1098 #if 0
1099           POOL_DEBUG(SOLV_DEBUG_STATS, "%s -> %s\n", pool_id2str(pool, id), pool_id2str(pool, did));
1100 #endif
1101           break;
1102         case REPOKEY_TYPE_IDARRAY:
1103         case REPOKEY_TYPE_REL_IDARRAY:
1104           if (!s || id < INTERESTED_START || id > INTERESTED_END)
1105             {
1106               dps = dp;
1107               dp = data_skip(dp, REPOKEY_TYPE_IDARRAY);
1108               if (keys[key].storage != KEY_STORAGE_INCORE)
1109                 break;
1110               if (idmap)
1111                 incore_map_idarray(&data, dps, idmap, numid + numrel);
1112               else
1113                 incore_add_blob(&data, dps, dp - dps);
1114               break;
1115             }
1116           ido = idarraydatap - repo->idarraydata;
1117           if (keys[key].type == REPOKEY_TYPE_IDARRAY)
1118             dp = data_read_idarray(dp, &idarraydatap, idmap, numid + numrel, &data);
1119           else if (id == SOLVABLE_REQUIRES)
1120             dp = data_read_rel_idarray(dp, &idarraydatap, idmap, numid + numrel, &data, SOLVABLE_PREREQMARKER);
1121           else if (id == SOLVABLE_PROVIDES)
1122             dp = data_read_rel_idarray(dp, &idarraydatap, idmap, numid + numrel, &data, SOLVABLE_FILEMARKER);
1123           else
1124             dp = data_read_rel_idarray(dp, &idarraydatap, idmap, numid + numrel, &data, 0);
1125           if (idarraydatap > idarraydataend)
1126             {
1127               data.error = pool_error(pool, SOLV_ERROR_OVERFLOW, "idarray overflow");
1128               break;
1129             }
1130           if (id == SOLVABLE_PROVIDES)
1131             s->provides = ido;
1132           else if (id == SOLVABLE_OBSOLETES)
1133             s->obsoletes = ido;
1134           else if (id == SOLVABLE_CONFLICTS)
1135             s->conflicts = ido;
1136           else if (id == SOLVABLE_REQUIRES)
1137             s->requires = ido;
1138           else if (id == SOLVABLE_RECOMMENDS)
1139             s->recommends= ido;
1140           else if (id == SOLVABLE_SUPPLEMENTS)
1141             s->supplements = ido;
1142           else if (id == SOLVABLE_SUGGESTS)
1143             s->suggests = ido;
1144           else if (id == SOLVABLE_ENHANCES)
1145             s->enhances = ido;
1146 #if 0
1147           POOL_DEBUG(SOLV_DEBUG_STATS, "%s ->\n", pool_id2str(pool, id));
1148           for (; repo->idarraydata[ido]; ido++)
1149             POOL_DEBUG(SOLV_DEBUG_STATS,"  %s\n", pool_dep2str(pool, repo->idarraydata[ido]));
1150 #endif
1151           break;
1152         case REPOKEY_TYPE_FIXARRAY:
1153         case REPOKEY_TYPE_FLEXARRAY:
1154           if (!keydepth)
1155             needchunk = 1;
1156           if (keydepth == sizeof(stack)/sizeof(*stack))
1157             {
1158               data.error = pool_error(pool, SOLV_ERROR_OVERFLOW, "array stack overflow");
1159               break;
1160             }
1161           stack[keydepth++] = nentries;
1162           stack[keydepth++] = keyp - schemadata;
1163           stack[keydepth++] = 0;
1164           dp = data_read_id_max(dp, &nentries, 0, 0, &data);
1165           incore_add_id(&data, nentries);
1166           if (!nentries)
1167             {
1168               /* zero size array? */
1169               keydepth -= 2;
1170               nentries = stack[--keydepth];
1171               break;
1172             }
1173           if (keydepth == 3 && id == REPOSITORY_SOLVABLES)
1174             {
1175               /* horray! here come the solvables */
1176               if (nentries != numsolv)
1177                 {
1178                   data.error = pool_error(pool, SOLV_ERROR_CORRUPT, "inconsistent number of solvables: %d %d", nentries, numsolv);
1179                   break;
1180                 }
1181               if (idarraydatap)
1182                 {
1183                   data.error = pool_error(pool, SOLV_ERROR_CORRUPT, "more than one solvable block");
1184                   break;
1185                 }
1186               if ((flags & REPO_EXTEND_SOLVABLES) != 0)
1187                 s = pool_id2solvable(pool, extendstart);
1188               else
1189                 s = pool_id2solvable(pool, repo_add_solvable_block(repo, numsolv));
1190               data.start = s - pool->solvables;
1191               data.end = data.start + numsolv;
1192               repodata_extend_block(&data, data.start, numsolv);
1193               for (i = 1; i < numkeys; i++)
1194                 {
1195                   id = keys[i].name;
1196                   if ((keys[i].type == REPOKEY_TYPE_IDARRAY || keys[i].type == REPOKEY_TYPE_REL_IDARRAY)
1197                       && id >= INTERESTED_START && id <= INTERESTED_END)
1198                     size_idarray += keys[i].size;
1199                 }
1200               /* allocate needed space in repo */
1201               /* we add maxsize because it is an upper limit for all idarrays, thus we can't overflow */
1202               repo_reserve_ids(repo, 0, size_idarray + maxsize + 1);
1203               idarraydatap = repo->idarraydata + repo->idarraysize;
1204               repo->idarraysize += size_idarray;
1205               idarraydataend = idarraydatap + size_idarray;
1206               repo->lastoff = 0;
1207               if (have_incoredata)
1208                 data.incoreoffset[(s - pool->solvables) - data.start] = data.incoredatalen;
1209             }
1210           nentries--;
1211           dp = data_read_id_max(dp, &id, 0, numschemata, &data);
1212           incore_add_id(&data, id);
1213           if (keys[key].type == REPOKEY_TYPE_FIXARRAY)
1214             {
1215               if (!id)
1216                 data.error = pool_error(pool, SOLV_ERROR_CORRUPT, "illegal fixarray");
1217               stack[keydepth - 1] = id;
1218             }
1219           keyp = schemadata + schemata[id];
1220           break;
1221         case REPOKEY_TYPE_NUM:
1222           if (!(solvflags & SOLV_FLAG_SIZE_BYTES) && keys[key].storage == KEY_STORAGE_INCORE &&
1223                 (id == SOLVABLE_INSTALLSIZE || id == SOLVABLE_DOWNLOADSIZE || id == DELTA_DOWNLOADSIZE))
1224             {
1225               /* old solv file with sizes in kilos. transcode. */
1226               dp = data_read_id(dp, &id);
1227               incore_add_sizek(&data, (unsigned int)id);
1228               break;
1229             }
1230           /* FALLTHROUGH */
1231         default:
1232           if (id == RPM_RPMDBID && s && (keys[key].type == REPOKEY_TYPE_U32 || keys[key].type == REPOKEY_TYPE_NUM))
1233             {
1234               if (keys[key].type == REPOKEY_TYPE_U32)
1235                 dp = data_read_u32(dp, (unsigned int *)&id);
1236               else
1237                 dp = data_read_id_max(dp, &id, 0, 0, &data);
1238               if (!repo->rpmdbid)
1239                 repo->rpmdbid = repo_sidedata_create(repo, sizeof(Id));
1240               repo->rpmdbid[(s - pool->solvables) - repo->start] = id;
1241               break;
1242             }
1243           dps = dp;
1244           dp = data_skip(dp, keys[key].type);
1245           if (keys[key].storage == KEY_STORAGE_INCORE)
1246             incore_add_blob(&data, dps, dp - dps);
1247           break;
1248         }
1249     }
1250   /* should shrink idarraydata again */
1251
1252   if (keydepth)
1253     data.error = pool_error(pool, SOLV_ERROR_EOF, "unexpected EOF, depth = %d", keydepth);
1254   if (!data.error)
1255     {
1256       if (dp > bufend)
1257         data.error = pool_error(pool, SOLV_ERROR_EOF, "buffer overrun");
1258     }
1259   solv_free(buf);
1260
1261   if (data.error)
1262     {
1263       /* free solvables */
1264       repo_free_solvable_block(repo, data.start, data.end - data.start, 1);
1265       /* free id array */
1266       repo->idarraysize -= size_idarray;
1267       /* free incore data */
1268       data.incoredata = solv_free(data.incoredata);
1269       data.incoredatalen = data.incoredatafree = 0;
1270     }
1271
1272   if (data.incoredatafree)
1273     {
1274       /* shrink excess size */
1275       data.incoredata = solv_realloc(data.incoredata, data.incoredatalen);
1276       data.incoredatafree = 0;
1277     }
1278
1279   for (i = 1; i < numkeys; i++)
1280     if (keys[i].storage == KEY_STORAGE_VERTICAL_OFFSET)
1281       break;
1282   if (i < numkeys && !data.error)
1283     {
1284       Id fileoffset = 0;
1285       unsigned int pagesize;
1286       
1287       /* we have vertical data, make it available */
1288       data.verticaloffset = solv_calloc(numkeys, sizeof(Id));
1289       for (i = 1; i < numkeys; i++)
1290         if (keys[i].storage == KEY_STORAGE_VERTICAL_OFFSET)
1291           {
1292             data.verticaloffset[i] = fileoffset;
1293             fileoffset += keys[i].size;
1294           }
1295       data.lastverticaloffset = fileoffset;
1296       pagesize = read_u32(&data);
1297       data.error = repopagestore_read_or_setup_pages(&data.store, data.fp, pagesize, fileoffset);
1298       if (data.error == SOLV_ERROR_EOF)
1299         pool_error(pool, data.error, "repopagestore setup: unexpected EOF");
1300       else if (data.error)
1301         pool_error(pool, data.error, "repopagestore setup failed");
1302     }
1303   else
1304     {
1305       /* no longer needed */
1306       data.fp = 0;
1307     }
1308   solv_free(idmap);
1309
1310   if (data.error)
1311     {
1312       /* XXX: free repodata? */
1313       return data.error;
1314     }
1315
1316   if (parent)
1317     {
1318       /* overwrite stub repodata */
1319       repodata_freedata(parent);
1320       data.repodataid = parent->repodataid;
1321       *parent = data;
1322     }
1323   else
1324     {
1325       /* make it available as new repodata */
1326       if (!repo->nrepodata)
1327         {
1328           repo->nrepodata = 1;
1329           repo->repodata = solv_calloc(2, sizeof(data));
1330         }
1331       else
1332         repo->repodata = solv_realloc2(repo->repodata, repo->nrepodata + 1, sizeof(data));
1333       data.repodataid = repo->nrepodata;
1334       repo->repodata[repo->nrepodata++] = data;
1335     }
1336
1337   /* create stub repodata entries for all external */
1338   if (!(flags & SOLV_ADD_NO_STUBS) && !parent)
1339     {
1340       for (key = 1 ; key < data.nkeys; key++)
1341         if (data.keys[key].name == REPOSITORY_EXTERNAL && data.keys[key].type == REPOKEY_TYPE_FLEXARRAY)
1342           break;
1343       if (key < data.nkeys)
1344         repodata_create_stubs(repo->repodata + (repo->nrepodata - 1));
1345     }
1346
1347   POOL_DEBUG(SOLV_DEBUG_STATS, "repo_add_solv took %d ms\n", solv_timems(now));
1348   POOL_DEBUG(SOLV_DEBUG_STATS, "repo size: %d solvables\n", repo->nsolvables);
1349   POOL_DEBUG(SOLV_DEBUG_STATS, "repo memory used: %d K incore, %d K idarray\n", data.incoredatalen/1024, repo->idarraysize / (int)(1024/sizeof(Id)));
1350   return 0;
1351 }
1352