DRD: Always invoke VG_(cli_free)() before the stop_using_mem callback.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11633
This commit is contained in:
Bart Van Assche 2011-03-12 12:43:39 +00:00
parent 73c5a1b3a3
commit 3ced345153
3 changed files with 9 additions and 8 deletions

View File

@ -81,7 +81,7 @@ static Bool handle_client_request(ThreadId vg_tid, UWord* arg, UWord* ret)
break;
case VG_USERREQ__FREELIKE_BLOCK:
if (arg[1] && ! DRD_(freelike_block)(vg_tid, arg[1]/*addr*/))
if (arg[1] && ! DRD_(freelike_block)(vg_tid, arg[1]/*addr*/, False))
{
GenericErrInfo GEI = {
.tid = DRD_(thread_get_running_tid)(),

View File

@ -109,19 +109,18 @@ void DRD_(malloclike_block)(const ThreadId tid, const Addr p, const SizeT size)
static void handle_free(ThreadId tid, void* p)
{
tl_assert(p);
Bool success;
if (DRD_(freelike_block)(tid, (Addr)p))
VG_(cli_free)(p);
else
tl_assert(False);
tl_assert(p);
success = DRD_(freelike_block)(tid, (Addr)p, True);
tl_assert(success);
}
/**
* Remove the information that was stored by DRD_(malloclike_block)() about
* a memory block.
*/
Bool DRD_(freelike_block)(const ThreadId tid, const Addr p)
Bool DRD_(freelike_block)(const ThreadId tid, const Addr p, const Bool dealloc)
{
DRD_Chunk* mc;
@ -133,6 +132,8 @@ Bool DRD_(freelike_block)(const ThreadId tid, const Addr p)
if (mc)
{
tl_assert(p == mc->data);
if (dealloc)
VG_(cli_free)((void*)p);
if (mc->size > 0)
s_stop_using_mem_callback(mc->data, mc->size);
VG_(free)(mc);

View File

@ -38,7 +38,7 @@ typedef void (*StopUsingMem)(const Addr a1, const SizeT len);
void DRD_(register_malloc_wrappers)(const StartUsingMem start_callback,
const StopUsingMem stop_callback);
void DRD_(malloclike_block)(const ThreadId tid, const Addr p, const SizeT size);
Bool DRD_(freelike_block)(const ThreadId tid, const Addr p);
Bool DRD_(freelike_block)(const ThreadId tid, const Addr p, const Bool dealloc);
Bool DRD_(heap_addrinfo)(Addr const a,
Addr* const data,
SizeT* const size,