]> git.mxchange.org Git - simgear.git/blobdiff - simgear/nasal/hash.c
Cygwin fixes.
[simgear.git] / simgear / nasal / hash.c
index 1de3fdf51255a405b57332361dc277e355541aff..5730fdf310b21d3bbdbd1173ac31307506580740 100644 (file)
@@ -54,6 +54,7 @@ static struct HashRec* realloc(struct naHash* hash)
     struct HashRec *h, *h0 = hash->rec;
     int lga, cols, need = h0 ? h0->size - h0->dels : MIN_HASH_SIZE;
 
+    if(need < MIN_HASH_SIZE) need = MIN_HASH_SIZE;
     for(lga=0; 1<<lga <= need; lga++);
     cols = 1<<lga;
     h = naAlloc(sizeof(struct HashRec) +
@@ -117,7 +118,7 @@ static struct HashNode* find(struct naHash* hash, naRef key)
 static void tmpStr(naRef* out, struct naStr* str, char* key)
 {
     str->len = 0;
-    str->data = key;
+    str->data = (unsigned char*)key;
     while(key[str->len]) str->len++;
     *out = naNil();
     out->ref.ptr.str = str;
@@ -169,7 +170,7 @@ void naHash_newsym(struct naHash* hash, naRef* sym, naRef* val)
 {
     int col;
     struct HashRec* h = hash->rec;
-    if(!h || h->size >= 1<<h->lgalloced)
+    while(!h || h->size >= 1<<h->lgalloced)
         h = realloc(hash);
     col = (HASH_MAGIC * sym->ref.ptr.str->hashcode) >> (32 - h->lgalloced);
     INSERT(h, *sym, *val, col);