forked from enlightenment/efl
eo: let's handle memory allocation gracefully.
This commit is contained in:
parent
c6309b44b2
commit
cecd19803e
|
@ -73,6 +73,7 @@ _data_set(Eo *obj, void *class_data, va_list *list)
|
|||
eo_do(obj, eo_base_data_del(key));
|
||||
|
||||
node = malloc(sizeof(Eo_Generic_Data_Node));
|
||||
if (!node) return;
|
||||
node->key = eina_stringshare_add(key);
|
||||
node->data = (void *) data;
|
||||
node->free_func = free_func;
|
||||
|
@ -157,13 +158,16 @@ _wref_add(Eo *obj, void *class_data, va_list *list)
|
|||
{
|
||||
Private_Data *pd = (Private_Data *) class_data;
|
||||
size_t count;
|
||||
Eo ***tmp;
|
||||
|
||||
EO_PARAMETER_GET(Eo **, wref, list);
|
||||
|
||||
count = _wref_count(pd);
|
||||
count += 1; /* New wref. */
|
||||
|
||||
pd->wrefs= realloc(pd->wrefs, sizeof(*pd->wrefs) * (count + 1));
|
||||
tmp = realloc(pd->wrefs, sizeof(*pd->wrefs) * (count + 1));
|
||||
if (!tmp) return ;
|
||||
pd->wrefs = tmp;
|
||||
|
||||
pd->wrefs[count - 1] = wref;
|
||||
pd->wrefs[count] = NULL;
|
||||
|
@ -216,8 +220,11 @@ _wref_del(Eo *obj, void *class_data, va_list *list)
|
|||
|
||||
if (count > 1)
|
||||
{
|
||||
Eo ***tmp;
|
||||
// No count--; because of the NULL that is not included in the count. */
|
||||
pd->wrefs = realloc(pd->wrefs, sizeof(*pd->wrefs) * count);
|
||||
tmp = realloc(pd->wrefs, sizeof(*pd->wrefs) * count);
|
||||
if (!tmp) return ;
|
||||
pd->wrefs = tmp;
|
||||
pd->wrefs[count - 1] = NULL;
|
||||
}
|
||||
else
|
||||
|
@ -370,6 +377,7 @@ _ev_cb_priority_add(Eo *obj, void *class_data, va_list *list)
|
|||
EO_PARAMETER_GET(const void *, data, list);
|
||||
|
||||
cb = calloc(1, sizeof(*cb));
|
||||
if (!cb) return ;
|
||||
cb->items.item.desc = desc;
|
||||
cb->items.item.func = func;
|
||||
cb->func_data = (void *) data;
|
||||
|
@ -421,6 +429,7 @@ _ev_cb_array_priority_add(Eo *obj, void *class_data, va_list *list)
|
|||
EO_PARAMETER_GET(const void *, data, list);
|
||||
|
||||
cb = calloc(1, sizeof(*cb));
|
||||
if (!cb) return ;
|
||||
cb->func_data = (void *) data;
|
||||
cb->priority = priority;
|
||||
cb->items.item_array = array;
|
||||
|
@ -647,7 +656,9 @@ _eo_dbg_info_copy(const Eina_Value_Type *type EINA_UNUSED, const void *_src, voi
|
|||
{
|
||||
const Eo_Dbg_Info **src = (const Eo_Dbg_Info **) _src;
|
||||
Eo_Dbg_Info **dst = _dst;
|
||||
|
||||
*dst = calloc(1, sizeof(Eo_Dbg_Info));
|
||||
if (!*dst) return EINA_FALSE;
|
||||
(*dst)->name = eina_stringshare_ref((*src)->name);
|
||||
eina_value_copy(&((*src)->value), &((*dst)->value));
|
||||
return EINA_TRUE;
|
||||
|
|
Loading…
Reference in New Issue