forked from enlightenment/efl
* eina: call malloc only when content is requested from the pool.
SVN revision: 52543
This commit is contained in:
parent
68f1a20306
commit
80bbb4584c
|
@ -94,6 +94,16 @@ eina_one_big_malloc(void *data, __UNUSED__ unsigned int size)
|
|||
goto on_exit;
|
||||
}
|
||||
|
||||
if (!pool->base)
|
||||
{
|
||||
pool->base = malloc(pool->item_size * pool->max);
|
||||
if (!pool->base)
|
||||
{
|
||||
eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
|
||||
goto retry_smaller;
|
||||
}
|
||||
}
|
||||
|
||||
if (pool->served < pool->max)
|
||||
{
|
||||
mem = pool->base + (pool->served++ *pool->item_size);
|
||||
|
@ -101,7 +111,8 @@ eina_one_big_malloc(void *data, __UNUSED__ unsigned int size)
|
|||
goto on_exit;
|
||||
}
|
||||
|
||||
eina_error_set(0);
|
||||
retry_smaller:
|
||||
eina_error_set(0);
|
||||
mem = malloc(pool->item_size);
|
||||
if (!mem)
|
||||
eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
|
||||
|
@ -187,13 +198,6 @@ eina_one_big_init(const char *context,
|
|||
memcpy((char *)pool->name, context, length);
|
||||
}
|
||||
|
||||
pool->base = malloc(pool->item_size * pool->max);
|
||||
if (!pool->base)
|
||||
{
|
||||
free(pool);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef EFL_HAVE_THREADS
|
||||
# ifdef EFL_HAVE_POSIX_THREADS
|
||||
pthread_mutex_init(&pool->mutex, NULL);
|
||||
|
|
Loading…
Reference in New Issue