Added check for address being freed by mempool free

When blender is built in debug mode, BLI_mempool_free will
ensure address passed to the function actually belongs to
this pool.

--
svn merge -r58710:58711 ^/branches/soc-2013-depsgraph_mt
This commit is contained in:
Sergey Sharybin
2013-08-19 10:18:25 +00:00
parent 552d068565
commit bec9bcc14c

View File

@@ -258,6 +258,22 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr)
{
BLI_freenode *newhead = addr;
#ifndef NDEBUG
{
BLI_mempool_chunk *chunk;
bool found = false;
for (chunk = pool->chunks.first; chunk; chunk = chunk->next) {
if ((char*)addr >= (char*)chunk->data && (char*)addr < (char*)chunk->data + pool->csize) {
found = true;
break;
}
}
if (!found) {
BLI_assert(!"Attempt to free data which is not in pool.\n");
}
}
#endif
if (pool->flag & BLI_MEMPOOL_ALLOW_ITER) {
#ifndef NDEBUG
/* this will detect double free's */