forked from enlightenment/efl
Add valgrind support to one_big mempool.
SVN revision: 53428
This commit is contained in:
parent
9733a55c22
commit
5b4996881e
|
@ -7,7 +7,8 @@ AM_CPPFLAGS = \
|
|||
-I$(top_srcdir)/src/lib \
|
||||
-I$(top_builddir)/src/lib \
|
||||
@EINA_CPPFLAGS@ \
|
||||
@EFL_EINA_BUILD@
|
||||
@EFL_EINA_BUILD@ \
|
||||
@VALGRIND_CFLAGS@
|
||||
|
||||
if EINA_BUILD_ONE_BIG
|
||||
if !EINA_STATIC_BUILD_ONE_BIG
|
||||
|
|
|
@ -36,6 +36,10 @@
|
|||
#include "eina_mempool.h"
|
||||
#include "eina_trash.h"
|
||||
|
||||
#ifndef NVALGRIND
|
||||
# include <valgrind/memcheck.h>
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#include "eina_private.h"
|
||||
#include "eina_log.h"
|
||||
|
@ -89,6 +93,9 @@ eina_one_big_malloc(void *data, __UNUSED__ unsigned int size)
|
|||
|
||||
if (pool->empty)
|
||||
{
|
||||
#ifndef NVALGRIND
|
||||
VALGRIND_MAKE_MEM_DEFINED(pool->empty, pool->item_size);
|
||||
#endif
|
||||
mem = eina_trash_pop(&pool->empty);
|
||||
pool->usage++;
|
||||
goto on_exit;
|
||||
|
@ -102,6 +109,9 @@ eina_one_big_malloc(void *data, __UNUSED__ unsigned int size)
|
|||
eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
|
||||
goto retry_smaller;
|
||||
}
|
||||
#ifndef NVALGRIND
|
||||
VALGRIND_MAKE_MEM_NOACCESS(pool->base, pool->item_size * pool->max);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (pool->served < pool->max)
|
||||
|
@ -118,6 +128,9 @@ eina_one_big_malloc(void *data, __UNUSED__ unsigned int size)
|
|||
eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
|
||||
else
|
||||
pool->over++;
|
||||
#ifndef NVALGRIND
|
||||
VALGRIND_MAKE_MEM_NOACCESS(mem, pool->item_size);
|
||||
#endif
|
||||
|
||||
on_exit:
|
||||
#ifdef EFL_HAVE_THREADS
|
||||
|
@ -126,6 +139,10 @@ on_exit:
|
|||
# else
|
||||
ReleaseMutex(pool->mutex);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef NVALGRIND
|
||||
VALGRIND_MEMPOOL_ALLOC(pool, mem, pool->item_size);
|
||||
#endif
|
||||
return mem;
|
||||
}
|
||||
|
@ -155,6 +172,10 @@ eina_one_big_free(void *data, void *ptr)
|
|||
pool->over--;
|
||||
}
|
||||
|
||||
#ifndef NVALGRIND
|
||||
VALGRIND_MEMPOOL_FREE(pool, ptr);
|
||||
#endif
|
||||
|
||||
#ifdef EFL_HAVE_THREADS
|
||||
# ifdef EFL_HAVE_POSIX_THREADS
|
||||
pthread_mutex_unlock(&pool->mutex);
|
||||
|
@ -206,6 +227,10 @@ eina_one_big_init(const char *context,
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef NVALGRIND
|
||||
VALGRIND_CREATE_MEMPOOL(pool, 0, 1);
|
||||
#endif
|
||||
|
||||
return pool;
|
||||
}
|
||||
|
||||
|
@ -230,6 +255,10 @@ eina_one_big_shutdown(void *data)
|
|||
|
||||
#endif
|
||||
|
||||
#ifndef NVALGRIND
|
||||
VALGRIND_DESTROY_MEMPOOL(pool);
|
||||
#endif
|
||||
|
||||
free(pool->base);
|
||||
free(pool);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue