forked from enlightenment/efl
eina: correctly remove reference from hash and make cow garbage collector work.
This commit is contained in:
parent
9157c51f32
commit
78984b9e7a
|
@ -201,7 +201,7 @@ _eina_cow_hash_del(Eina_Cow *cow,
|
||||||
if (!ref->hashed) return ;
|
if (!ref->hashed) return ;
|
||||||
|
|
||||||
current_cow_size = cow->struct_size;
|
current_cow_size = cow->struct_size;
|
||||||
eina_hash_del(cow->match, data, ref);
|
eina_hash_del(cow->match, data, data);
|
||||||
ref->hashed = EINA_FALSE;
|
ref->hashed = EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,7 +493,6 @@ eina_cow_done(Eina_Cow *cow,
|
||||||
VALGRIND_MAKE_MEM_NOACCESS(ref, sizeof (*ref));
|
VALGRIND_MAKE_MEM_NOACCESS(ref, sizeof (*ref));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
gc = eina_mempool_malloc(gc_pool, sizeof (Eina_Cow_GC));
|
gc = eina_mempool_malloc(gc_pool, sizeof (Eina_Cow_GC));
|
||||||
if (!gc) return ; /* That one will not get gced this time */
|
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 */
|
/* Do handle hash and all funky merge think here */
|
||||||
data = EINA_COW_DATA_GET(gc->ref);
|
data = EINA_COW_DATA_GET(gc->ref);
|
||||||
|
|
||||||
|
#ifndef NVALGRIND
|
||||||
|
VALGRIND_MAKE_MEM_DEFINED(gc->ref, sizeof (*ref));
|
||||||
|
#endif
|
||||||
gc->ref->togc = EINA_FALSE;
|
gc->ref->togc = EINA_FALSE;
|
||||||
|
|
||||||
current_cow_size = cow->struct_size;
|
current_cow_size = cow->struct_size;
|
||||||
match = eina_hash_find(cow->match, data);
|
match = eina_hash_find(cow->match, data);
|
||||||
if (match)
|
if (match)
|
||||||
{
|
{
|
||||||
|
if (match == data) abort();
|
||||||
eina_cow_free(cow, data);
|
eina_cow_free(cow, data);
|
||||||
|
|
||||||
ref = EINA_COW_PTR_GET(match);
|
ref = EINA_COW_PTR_GET(match);
|
||||||
#ifndef NVALGRIND
|
#ifndef NVALGRIND
|
||||||
VALGRIND_MAKE_MEM_DEFINED(ref, sizeof (*ref));
|
VALGRIND_MAKE_MEM_DEFINED(ref, sizeof (*ref));
|
||||||
#endif
|
#endif
|
||||||
*((void**)gc->dst) = match;
|
*((void**)gc->dst) = match;
|
||||||
ref->refcount++;
|
ref->refcount++;
|
||||||
#ifndef NVALGRIND
|
#ifndef NVALGRIND
|
||||||
|
@ -584,6 +587,9 @@ eina_cow_gc(Eina_Cow *cow)
|
||||||
eina_hash_direct_add(cow->match, data, data);
|
eina_hash_direct_add(cow->match, data, data);
|
||||||
gc->ref->hashed = EINA_TRUE;
|
gc->ref->hashed = EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
#ifndef NVALGRIND
|
||||||
|
VALGRIND_MAKE_MEM_NOACCESS(gc->ref, sizeof (*ref));
|
||||||
|
#endif
|
||||||
|
|
||||||
eina_hash_del(cow->togc, &gc->ref, gc);
|
eina_hash_del(cow->togc, &gc->ref, gc);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue