[1/5] wsdapi: Implement WSD LinkedMemory functions [try 2]

Alexandre Julliard julliard at winehq.org
Fri Apr 28 03:41:24 CDT 2017


Owen Rudge <orudge at 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 at winehq.org



More information about the wine-devel mailing list