forked from enlightenment/efl
eina: make it possible to disable Eina_Cow GC at instantiation time.
This commit is contained in:
parent
3b9f8e4847
commit
7ebe7373e6
|
@ -98,8 +98,8 @@ edje_init(void)
|
|||
goto shutdown_all;
|
||||
}
|
||||
|
||||
_edje_calc_params_map_cow = eina_cow_add("Edje Calc Params Map", sizeof (Edje_Calc_Params), 8, &default_calc_map);
|
||||
_edje_calc_params_physics_cow= eina_cow_add("Edje Calc Params Physics", sizeof (Edje_Calc_Params_Physics), 8, &default_calc_physics);
|
||||
_edje_calc_params_map_cow = eina_cow_add("Edje Calc Params Map", sizeof (Edje_Calc_Params), 8, &default_calc_map, EINA_TRUE);
|
||||
_edje_calc_params_physics_cow= eina_cow_add("Edje Calc Params Physics", sizeof (Edje_Calc_Params_Physics), 8, &default_calc_physics, EINA_TRUE);
|
||||
|
||||
eina_log_timing(_edje_default_log_dom,
|
||||
EINA_LOG_STATE_STOP,
|
||||
|
|
|
@ -319,7 +319,7 @@ eina_cow_shutdown(void)
|
|||
}
|
||||
|
||||
EAPI Eina_Cow *
|
||||
eina_cow_add(const char *name, unsigned int struct_size, unsigned int step, const void *default_value)
|
||||
eina_cow_add(const char *name, unsigned int struct_size, unsigned int step, const void *default_value, Eina_Bool gc)
|
||||
{
|
||||
const char *choice, *tmp;
|
||||
Eina_Cow *cow;
|
||||
|
@ -362,7 +362,10 @@ eina_cow_add(const char *name, unsigned int struct_size, unsigned int step, cons
|
|||
NULL,
|
||||
6);
|
||||
#endif
|
||||
if (gc)
|
||||
cow->togc = eina_hash_pointer_new(_eina_cow_gc_free);
|
||||
else
|
||||
cow->togc = NULL;
|
||||
cow->default_value = default_value;
|
||||
cow->struct_size = struct_size;
|
||||
cow->total_size = total_size;
|
||||
|
@ -389,8 +392,7 @@ eina_cow_del(Eina_Cow *cow)
|
|||
|
||||
eina_mempool_del(cow->pool);
|
||||
eina_hash_free(cow->match);
|
||||
eina_hash_free(cow->togc);
|
||||
|
||||
if (cow->togc) eina_hash_free(cow->togc);
|
||||
free(cow);
|
||||
}
|
||||
|
||||
|
@ -542,7 +544,7 @@ eina_cow_done(Eina_Cow *cow,
|
|||
VALGRIND_MAKE_MEM_NOACCESS(ref, sizeof (*ref));
|
||||
#endif
|
||||
|
||||
if (!needed_gc) return ;
|
||||
if (!cow->togc || !needed_gc) return ;
|
||||
|
||||
#ifndef NVALGRIND
|
||||
VALGRIND_MAKE_MEM_DEFINED(ref, sizeof (*ref));
|
||||
|
@ -572,6 +574,7 @@ eina_cow_memcpy(Eina_Cow *cow,
|
|||
EINA_COW_PTR_MAGIC_CHECK(ref);
|
||||
ref->refcount++;
|
||||
|
||||
if (cow->togc)
|
||||
_eina_cow_togc_del(cow, ref);
|
||||
|
||||
#ifndef NVALGRIND
|
||||
|
@ -595,7 +598,8 @@ eina_cow_gc(Eina_Cow *cow)
|
|||
|
||||
EINA_COW_MAGIC_CHECK(cow);
|
||||
|
||||
if (!eina_hash_population(cow->togc)) return EINA_FALSE;
|
||||
if (!cow->togc || !eina_hash_population(cow->togc))
|
||||
return EINA_FALSE;
|
||||
|
||||
it = eina_hash_iterator_data_new(cow->togc);
|
||||
r = eina_iterator_next(it, (void**) &gc);
|
||||
|
|
|
@ -58,9 +58,10 @@ typedef void Eina_Cow_Data;
|
|||
* @param struct_size The size of the object from this pool.
|
||||
* @param step How many object to allocate when the pool get empty.
|
||||
* @param default_value The default value returned by this pool.
|
||||
* @param gc Is it possible to run the garbage collection on this pool.
|
||||
* @return a valid new Eina_Cow or @c NULL on error.
|
||||
*/
|
||||
EAPI Eina_Cow *eina_cow_add(const char *name, unsigned int struct_size, unsigned int step, const void *default_value) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI Eina_Cow *eina_cow_add(const char *name, unsigned int struct_size, unsigned int step, const void *default_value, Eina_Bool gc) EINA_WARN_UNUSED_RESULT;
|
||||
|
||||
/**
|
||||
* @brief Destroy an Eina_Cow pool and all the allocated memory
|
||||
|
|
|
@ -266,15 +266,18 @@ _init_cow(Eo *eo_obj)
|
|||
evas_object_image_load_opts_cow = eina_cow_add("Evas_Object_Image load opts",
|
||||
sizeof (Evas_Object_Image_Load_Opts),
|
||||
8,
|
||||
&default_load_opts);
|
||||
&default_load_opts,
|
||||
EINA_TRUE);
|
||||
evas_object_image_pixels_cow = eina_cow_add("Evas_Object_Image pixels",
|
||||
sizeof (Evas_Object_Image_Pixels),
|
||||
8,
|
||||
&default_pixels);
|
||||
&default_pixels,
|
||||
EINA_TRUE);
|
||||
evas_object_image_state_cow = eina_cow_add("Evas_Object_Image states",
|
||||
sizeof (Evas_Object_Image_State),
|
||||
8,
|
||||
&default_state);
|
||||
&default_state,
|
||||
EINA_TRUE);
|
||||
}
|
||||
if (!evas_object_image_load_opts_cow ||
|
||||
!evas_object_image_pixels_cow ||
|
||||
|
|
|
@ -46,9 +46,9 @@ _init_cow(void)
|
|||
{
|
||||
if (evas_object_map_cow && evas_object_proxy_cow && evas_object_state_cow) return EINA_TRUE;
|
||||
|
||||
evas_object_proxy_cow = eina_cow_add("Evas Object Proxy", sizeof (Evas_Object_Proxy_Data), 8, &default_proxy);
|
||||
evas_object_map_cow = eina_cow_add("Evas Object Map", sizeof (Evas_Object_Map_Data), 8, &default_map);
|
||||
evas_object_state_cow = eina_cow_add("Evas Object State", sizeof (Evas_Object_Protected_State), 64, &default_state);
|
||||
evas_object_proxy_cow = eina_cow_add("Evas Object Proxy", sizeof (Evas_Object_Proxy_Data), 8, &default_proxy, EINA_TRUE);
|
||||
evas_object_map_cow = eina_cow_add("Evas Object Map", sizeof (Evas_Object_Map_Data), 8, &default_map, EINA_TRUE);
|
||||
evas_object_state_cow = eina_cow_add("Evas Object State", sizeof (Evas_Object_Protected_State), 64, &default_state, EINA_FALSE);
|
||||
|
||||
if (!(evas_object_map_cow && evas_object_proxy_cow && evas_object_state_cow))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue