summaryrefslogtreecommitdiff
path: root/sal/rtl/source/alloc_arena.c
diff options
context:
space:
mode:
Diffstat (limited to 'sal/rtl/source/alloc_arena.c')
-rw-r--r--sal/rtl/source/alloc_arena.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/sal/rtl/source/alloc_arena.c b/sal/rtl/source/alloc_arena.c
index 1a74c7e36cae..e2735cc014e4 100644
--- a/sal/rtl/source/alloc_arena.c
+++ b/sal/rtl/source/alloc_arena.c
@@ -28,22 +28,13 @@
#define _BSD_SOURCE /* sys/mman.h: MAP_ANON */
#include "alloc_arena.h"
-#ifndef INCLUDED_RTL_ARENA_IMPL_H
#include "alloc_impl.h"
-#endif
#include "internal/once.h"
#include "sal/macros.h"
#include "osl/diagnose.h"
-#ifndef INCLUDED_STRING_H
#include <string.h>
-#endif
-
-#ifndef INCLUDED_STDIO_H
#include <stdio.h>
-#endif
-
-#include "sal/types.h"
#ifdef OS2
#undef OSL_TRACE
@@ -967,6 +958,7 @@ try_alloc:
if (result != 0)
{
rtl_arena_type * arena = result;
+ VALGRIND_CREATE_MEMPOOL(arena, 0, 0);
rtl_arena_constructor (arena);
if (!source_arena)
@@ -989,6 +981,7 @@ try_alloc:
{
rtl_arena_deactivate (arena);
rtl_arena_destructor (arena);
+ VALGRIND_DESTROY_MEMPOOL(arena);
rtl_arena_free (gp_arena_arena, arena, size);
}
}
@@ -1014,6 +1007,7 @@ SAL_CALL rtl_arena_destroy (
{
rtl_arena_deactivate (arena);
rtl_arena_destructor (arena);
+ VALGRIND_DESTROY_MEMPOOL(arena);
rtl_arena_free (gp_arena_arena, arena, sizeof(rtl_arena_type));
}
}
@@ -1069,6 +1063,9 @@ SAL_CALL rtl_arena_alloc (
rtl_arena_hash_insert (arena, segment);
+ OSL_DEBUG_ONLY(memset((void*)(segment->m_addr), 0x77777777, segment->m_size));
+ VALGRIND_MEMPOOL_ALLOC(arena, segment->m_addr, segment->m_size);
+
(*pSize) = segment->m_size;
addr = (void*)(segment->m_addr);
}
@@ -1112,6 +1109,10 @@ SAL_CALL rtl_arena_free (
{
rtl_arena_segment_type *next, *prev;
+ /* DEBUG ONLY: mark undefined, unallocated */
+ OSL_DEBUG_ONLY(memset((void*)(segment->m_addr), 0x33333333, segment->m_size));
+ VALGRIND_MEMPOOL_FREE(arena, segment->m_addr);
+
/* coalesce w/ adjacent free segment(s) */
rtl_arena_segment_coalesce (arena, segment);
@@ -1303,6 +1304,7 @@ rtl_arena_once_init (void)
static rtl_arena_type g_machdep_arena;
OSL_ASSERT(gp_machdep_arena == 0);
+ VALGRIND_CREATE_MEMPOOL(&g_machdep_arena, 0, 0);
rtl_arena_constructor (&g_machdep_arena);
gp_machdep_arena = rtl_arena_activate (
@@ -1319,6 +1321,7 @@ rtl_arena_once_init (void)
static rtl_arena_type g_default_arena;
OSL_ASSERT(gp_default_arena == 0);
+ VALGRIND_CREATE_MEMPOOL(&g_default_arena, 0, 0);
rtl_arena_constructor (&g_default_arena);
gp_default_arena = rtl_arena_activate (
@@ -1337,6 +1340,7 @@ rtl_arena_once_init (void)
static rtl_arena_type g_arena_arena;
OSL_ASSERT(gp_arena_arena == 0);
+ VALGRIND_CREATE_MEMPOOL(&g_arena_arena, 0, 0);
rtl_arena_constructor (&g_arena_arena);
gp_arena_arena = rtl_arena_activate (