[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wine-devel
Subject:    Re: [1/5] wsdapi: Implement WSD LinkedMemory functions [try 2]
From:       Alexandre Julliard <julliard () winehq ! org>
Date:       2017-04-28 8:41:24
Message-ID: 87mvb0zzyj.fsf () winehq ! org
[Download RAW message or body]

Owen Rudge <orudge@codeweavers.com> writes:

> +struct memory_allocation
> +{
> +    struct list entry;
> +    void *ptr;
> +
> +    struct list children;
> +};
> +
> +static struct list memory_allocations = LIST_INIT(memory_allocations);
> +
> +static struct memory_allocation *find_allocation(struct list *searchList, void *parent)
> +{
> +    struct memory_allocation *allocation, *childAllocation;
> +
> +    LIST_FOR_EACH_ENTRY(allocation, searchList, struct memory_allocation, entry)
> +    {
> +        if (allocation->ptr == parent)
> +        {
> +            return allocation;
> +        }
> +
> +        /* Search the children */
> +        childAllocation = find_allocation(&allocation->children, parent);
> +
> +        if (childAllocation != NULL)
> +        {
> +            return childAllocation;
> +        }
> +    }
> +
> +    return NULL;
> +}

You should probably store the child list at the start of the allocated
block or something like that, you don't want to go through the entire
list on every operation.

-- 
Alexandre Julliard
julliard@winehq.org



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic