opkg: making hash_table_insert works as real hash_table.
authorticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Mon, 15 Dec 2008 05:29:50 +0000 (05:29 +0000)
committerticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Mon, 15 Dec 2008 05:29:50 +0000 (05:29 +0000)
solving the update_file_ownership misbehaviour issue, and redundent installed files issue.

git-svn-id: http://opkg.googlecode.com/svn/trunk@159 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

libopkg/hash_table.c

index b03dd74edd9ebd1a0df702e6a6b63a07a926f353..e7f5a926b1f80971324a65d94c937b0fcdab3605 100644 (file)
@@ -139,8 +139,13 @@ int hash_table_insert(hash_table_t *hash, const char *key, void *value)
                * before we can hook up the value
                */
                if (0) opkg_message(NULL, OPKG_DEBUG2, "Function: %s. Value already in hash by collision for '%s' \n", __FUNCTION__, key);
-              while (hash_entry->next)
+              while (hash_entry->next) {
                    hash_entry = hash_entry->next;
+                    if (strcmp(hash_entry->key, key) == 0) {
+                        hash_entry->data = value;
+                        return 0;
+                    }
+               }
               hash_entry->next = (hash_entry_t *)malloc(sizeof(hash_entry_t));
               if (!hash_entry->next) {
                    return -ENOMEM;