[Bf-blender-cvs] [de81607] master: Fix error in ghash/gset_ensure_p_ex

Campbell Barton noreply at git.blender.org
Tue Mar 29 18:02:00 CEST 2016


Commit: de81607efca43830288cbaf03fe2044d7ca1ce53
Author: Campbell Barton
Date:   Wed Mar 30 03:00:26 2016 +1100
Branches: master
https://developer.blender.org/rBde81607efca43830288cbaf03fe2044d7ca1ce53

Fix error in ghash/gset_ensure_p_ex

The key is needed in the case the ghash resizes.
Caused regression T47984.

===================================================================

M	source/blender/blenlib/intern/BLI_ghash.c

===================================================================

diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c
index 3233a58..06946e5 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -850,8 +850,10 @@ bool BLI_ghash_ensure_p_ex(
 	const bool haskey = (e != NULL);
 
 	if (!haskey) {
+		/* pass 'key' incase we resize */
 		e = BLI_mempool_alloc(gh->entrypool);
-		ghash_insert_ex_keyonly_entry(gh, NULL, bucket_index, (Entry *)e);
+		ghash_insert_ex_keyonly_entry(gh, (void *)key, bucket_index, (Entry *)e);
+		e->e.key = NULL;  /* caller must re-assign */
 	}
 
 	*r_key = &e->e.key;
@@ -1406,8 +1408,10 @@ bool BLI_gset_ensure_p_ex(GSet *gs, const void *key, void ***r_key)
 	const bool haskey = (e != NULL);
 
 	if (!haskey) {
+		/* pass 'key' incase we resize */
 		e = BLI_mempool_alloc(((GHash *)gs)->entrypool);
-		ghash_insert_ex_keyonly_entry((GHash *)gs, NULL, bucket_index, (Entry *)e);
+		ghash_insert_ex_keyonly_entry((GHash *)gs, (void *)key, bucket_index, (Entry *)e);
+		e->key = NULL;  /* caller must re-assign */
 	}
 
 	*r_key = &e->key;




More information about the Bf-blender-cvs mailing list