cedric pushed a commit to branch master.
commit 78984b9e7a0eea48281f95fa8387847136ac873e
Author: Cedric BAIL <[email protected]>
Date: Mon Apr 1 18:38:24 2013 +0900
eina: correctly remove reference from hash and make cow garbage collector
work.
---
src/lib/eina/eina_cow.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/lib/eina/eina_cow.c b/src/lib/eina/eina_cow.c
index 0b5514c..3322841 100644
--- a/src/lib/eina/eina_cow.c
+++ b/src/lib/eina/eina_cow.c
@@ -201,7 +201,7 @@ _eina_cow_hash_del(Eina_Cow *cow,
if (!ref->hashed) return ;
current_cow_size = cow->struct_size;
- eina_hash_del(cow->match, data, ref);
+ eina_hash_del(cow->match, data, data);
ref->hashed = EINA_FALSE;
}
@@ -493,7 +493,6 @@ eina_cow_done(Eina_Cow *cow,
VALGRIND_MAKE_MEM_NOACCESS(ref, sizeof (*ref));
#endif
-
gc = eina_mempool_malloc(gc_pool, sizeof (Eina_Cow_GC));
if (!gc) return ; /* That one will not get gced this time */
@@ -561,18 +560,22 @@ eina_cow_gc(Eina_Cow *cow)
/* Do handle hash and all funky merge think here */
data = EINA_COW_DATA_GET(gc->ref);
+#ifndef NVALGRIND
+ VALGRIND_MAKE_MEM_DEFINED(gc->ref, sizeof (*ref));
+#endif
gc->ref->togc = EINA_FALSE;
current_cow_size = cow->struct_size;
match = eina_hash_find(cow->match, data);
if (match)
{
+ if (match == data) abort();
eina_cow_free(cow, data);
ref = EINA_COW_PTR_GET(match);
#ifndef NVALGRIND
VALGRIND_MAKE_MEM_DEFINED(ref, sizeof (*ref));
-#endif
+#endif
*((void**)gc->dst) = match;
ref->refcount++;
#ifndef NVALGRIND
@@ -584,6 +587,9 @@ eina_cow_gc(Eina_Cow *cow)
eina_hash_direct_add(cow->match, data, data);
gc->ref->hashed = EINA_TRUE;
}
+#ifndef NVALGRIND
+ VALGRIND_MAKE_MEM_NOACCESS(gc->ref, sizeof (*ref));
+#endif
eina_hash_del(cow->togc, &gc->ref, gc);
--
------------------------------------------------------------------------------
Own the Future-Intel® Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest.
Compete for recognition, cash, and the chance to get your game
on Steam. $5K grand prize plus 10 genre and skill prizes.
Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d