summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric Bail <cedric.bail@free.fr>2019-09-14 19:12:44 -0700
committerCedric Bail <cedric.bail@free.fr>2019-09-19 14:37:43 -0700
commit2fdad9294876f475225618e9f50d558a62c6bcf3 (patch)
tree55c7e6dc89e4d9a01ff6928d7892fb3c67f3fb88
parent9382bfc0bc1c6a5fb3aafce18094016b110036c0 (diff)
eina: add code to help debug leaking Eina_Value.
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Differential Revision: https://phab.enlightenment.org/D9942
-rw-r--r--src/lib/eina/eina_value.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/lib/eina/eina_value.c b/src/lib/eina/eina_value.c
index 3df0baa..63f45b9 100644
--- a/src/lib/eina/eina_value.c
+++ b/src/lib/eina/eina_value.c
@@ -5279,6 +5279,9 @@ typedef struct _Eina_Value_Inner_Mp Eina_Value_Inner_Mp;
5279struct _Eina_Value_Inner_Mp 5279struct _Eina_Value_Inner_Mp
5280{ 5280{
5281 Eina_Mempool *mempool; 5281 Eina_Mempool *mempool;
5282#ifdef DEBUG
5283 int size;
5284#endif
5282 int references; 5285 int references;
5283}; 5286};
5284 5287
@@ -5310,6 +5313,9 @@ _eina_value_inner_mp_get(int size)
5310 return NULL; 5313 return NULL;
5311 5314
5312 imp->references = 0; 5315 imp->references = 0;
5316#ifdef DEBUG
5317 imp->size = size;
5318#endif
5313 5319
5314 imp->mempool = eina_mempool_add(_eina_value_mp_choice, 5320 imp->mempool = eina_mempool_add(_eina_value_mp_choice,
5315 "Eina_Value_Inner_Mp", NULL, size, 16); 5321 "Eina_Value_Inner_Mp", NULL, size, 16);
@@ -5517,7 +5523,42 @@ eina_value_init(void)
5517Eina_Bool 5523Eina_Bool
5518eina_value_shutdown(void) 5524eina_value_shutdown(void)
5519{ 5525{
5526#ifdef DEBUG
5527 Eina_Iterator *it;
5528 Eina_Value_Inner_Mp *imp;
5529#endif
5530
5520 eina_lock_take(&_eina_value_inner_mps_lock); 5531 eina_lock_take(&_eina_value_inner_mps_lock);
5532
5533#ifdef DEBUG
5534 it = eina_hash_iterator_data_new(_eina_value_inner_mps);
5535 EINA_ITERATOR_FOREACH(it, imp)
5536 {
5537 Eina_Iterator *mit;
5538 Eina_Value *value;
5539
5540 fprintf(stderr, "There is still %i Eina_Value in pool of size %i\n",
5541 imp->references, imp->size);
5542 mit = eina_mempool_iterator_new(imp->mempool);
5543 EINA_ITERATOR_FOREACH(mit, value)
5544 {
5545 if (value->type)
5546 {
5547 char *str = eina_value_to_string(value);
5548 fprintf(stderr, "Value %p of type '%s' containing '%s' still allocated.\n",
5549 value, value->type->name, str);
5550 free(str);
5551 }
5552 else
5553 {
5554 fprintf(stderr, "Unknown type found for value %p\n", value);
5555 }
5556 }
5557 eina_iterator_free(mit);
5558 }
5559 eina_iterator_free(it);
5560#endif
5561
5521 if (eina_hash_population(_eina_value_inner_mps) != 0) 5562 if (eina_hash_population(_eina_value_inner_mps) != 0)
5522 ERR("Cannot free eina_value internal memory pools -- still in use!"); 5563 ERR("Cannot free eina_value internal memory pools -- still in use!");
5523 else 5564 else