revert pyhton3 part that was commit by mistake in #ab8b3ded
[platform/upstream/libsolv.git] / src / strpool.c
index 0d92beb..3ad0a80 100644 (file)
@@ -79,9 +79,7 @@ stringpool_clone(Stringpool *ss, Stringpool *from)
 Id
 stringpool_strn2id(Stringpool *ss, const char *str, unsigned int len, int create)
 {
-  Hashval h;
-  unsigned int hh;
-  Hashmask hashmask;
+  Hashval h, hh, hashmask, oldhashmask;
   int i;
   Id id;
   Hashtable hashtbl;
@@ -91,7 +89,7 @@ stringpool_strn2id(Stringpool *ss, const char *str, unsigned int len, int create
   if (!len)
     return STRID_EMPTY;
 
-  hashmask = ss->stringhashmask;
+  hashmask = oldhashmask = ss->stringhashmask;
   hashtbl = ss->stringhashtbl;
 
   /* expand hashtable if needed */
@@ -127,6 +125,16 @@ stringpool_strn2id(Stringpool *ss, const char *str, unsigned int len, int create
   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;