[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11105] branches/soc-2007-maike/source/ blender/blenlib/intern/BLI_ghash.c: BLI_ghash_lookup_reset correction

Miguel Torres Lima torreslima at gmail.com
Thu Jun 28 19:23:43 CEST 2007


Revision: 11105
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11105
Author:   maike
Date:     2007-06-28 19:23:43 +0200 (Thu, 28 Jun 2007)

Log Message:
-----------
BLI_ghash_lookup_reset correction

Modified Paths:
--------------
    branches/soc-2007-maike/source/blender/blenlib/intern/BLI_ghash.c

Modified: branches/soc-2007-maike/source/blender/blenlib/intern/BLI_ghash.c
===================================================================
--- branches/soc-2007-maike/source/blender/blenlib/intern/BLI_ghash.c	2007-06-28 17:06:16 UTC (rev 11104)
+++ branches/soc-2007-maike/source/blender/blenlib/intern/BLI_ghash.c	2007-06-28 17:23:43 UTC (rev 11105)
@@ -92,7 +92,7 @@
 	e->val= val;
 	e->next= gh->buckets[hash];
 	gh->buckets[hash]= e;
-	
+
 	if (++gh->nentries>gh->nbuckets*3) {
 		Entry *e, **old= gh->buckets;
 		int i, nold= gh->nbuckets;
@@ -130,14 +130,19 @@
 
 void* BLI_ghash_lookup_reset(GHash *gh, void *key) {
 	unsigned int hash= gh->hashfp(key)%gh->nbuckets;
-	Entry *e;
+	Entry *e, *d = NULL;
+	void *res;
 	
-	for (e= gh->buckets[hash]; e; e= e->next)
+	for (e= gh->buckets[hash]; e; e= e->next){
 	        if (gh->cmpfp(key, e->key)==0){
-		        e->key = NULL;
-			return e->val;
+		        res = e->val;
+			BLI_ghash_remove(gh, key, 0, 0);
+			
+			return res;
 		}
-	
+		d = e;
+	}
+
 	return NULL;
 }
 
@@ -188,7 +193,7 @@
 
 void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp) {
 	int i;
-	
+
 	for (i=0; i<gh->nbuckets; i++) {
 		Entry *e;
 		





More information about the Bf-blender-cvs mailing list