{
data.localpool = 1;
spool = &data.spool;
- spool->sstrings = 7 + sizeid + 1;
- spool->nstrings = numid < 2 ? 2 : numid;
- stringpool_shrink(spool); /* we misuse stringpool_shrink to alloc the stringpool in the correct size */
+ spool->stringspace = solv_malloc(7 + sizeid + 1);
+ spool->strings = solv_malloc2(numid < 2 ? 2 : numid, sizeof(Offset));
strcpy(spool->stringspace, "<NULL>");
spool->sstrings = 7;
spool->nstrings = 1;
}
else
{
+ Offset oldsstrings = spool->sstrings;
+
/* alloc id map for name and rel Ids. this maps ids in the solv files
* to the ids in our pool */
idmap = solv_calloc(numid + numrel, sizeof(Id));
{
if (sp >= strsp + sizeid)
{
- solv_free(hashtbl);
solv_free(idmap);
+ spool->nstrings = oldnstrings;
+ spool->sstrings = oldsstrings;
+ stringpool_freehash(spool);
return pool_error(pool, SOLV_ERROR_OVERFLOW, "not enough strings %d %d", i, numid);
}
if (!*sp) /* empty string */
{
Hashval h;
unsigned int hh;
- Hashmask hashmask;
+ Hashmask hashmask, oldhashmask;
int i;
Id id;
Hashtable hashtbl;
if (!len)
return STRID_EMPTY;
- hashmask = ss->stringhashmask;
+ hashmask = oldhashmask = ss->stringhashmask;
hashtbl = ss->stringhashtbl;
/* expand hashtable if needed */
if (id || !create) /* exit here if string found */
return id;
+ /* this should be a test for a flag that tells us if the
+ * correct blocking is used, but adding a flag would break
+ * the ABI. So we use the existance of the hash area as
+ * indication instead */
+ if (!oldhashmask)
+ {
+ ss->stringspace = solv_extend_resize(ss->stringspace, ss->sstrings + len + 1, 1, STRINGSPACE_BLOCK);
+ ss->strings = solv_extend_resize(ss->strings, ss->nstrings + 1, sizeof(Offset), STRING_BLOCK);
+ }
+
/* generate next id and save in table */
id = ss->nstrings++;
hashtbl[h] = id;