On Wed, Jan 25, 2017 at 6:50 PM, Evan Huus <eapa...@gmail.com> wrote:

> On my phone, but the short version is that there's no way to check this,
> and no efficient way to build it.
>
> Evan
>
>
Looking into the code it seems to me that the routine of free_all should
traverse all the allocated memory. I've written a code that mimics it, but
I'm still failing to have all the addresses for some type conversions.
That's the code I'm working on

// Check if 'address' belongs to the given scope.
gboolean
wmem_check_allocator_block(wmem_allocator_t* allocator, void* address)
{
    wmem_block_allocator_t *private_allocator =
(wmem_block_allocator_t*)allocator->private_data;
    wmem_block_hdr_t       *cur;
    wmem_block_chunk_t     *chunk;
    void* a = WMEM_DATA_TO_CHUNK(address);

    cur = private_allocator->block_list;

    while (cur) {
        chunk = WMEM_BLOCK_TO_CHUNK(cur);
        if (a == chunk)
            return TRUE;
        cur = cur->next;
    }
    return FALSE;
}

If I allocate a block and the allocator gives me 7c40 as address, the
function checks only 7c30. It looks like I'm casting/converting the
addresses the wrong way.
Any idea? Does this approach sound good, or am I completely following the
wrong path?

Thanks anyway.
Dario.
___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev@wireshark.org>
Archives:    https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-requ...@wireshark.org?subject=unsubscribe

Reply via email to