On Mon, Mar 13, 2017 at 3:01 AM, Timothy Arceri <tarc...@itsqueeze.com> wrote:
> The following patch will move disk_cache_put() into a thread queue
> so we need to be sure memory is not freed before the thread is
> completed. Here we move responsibility for releasing the memory
> onto the disk cache.

I think this is a fragile interface and very easy to mess up, cache
should just make a copy instead. You already do that at one callsite
anyway.

You could even do that while creating struct disk_cache_put_job to
avoid an extra malloc:

struct disk_cache_put_job {
   ...
   size_t size;
   uint8_t mem[0];
};
...
create_put_job(struct disk_cache *cache, const cache_key key,
               const void *data, size_t size)
{
   struct disk_cache_put_job *dc_job = malloc(sizeof(*dc_job) + size);
   ...
   memcpy(dc_job->mem, data, size);
   ...
}

That's of course just my opinion, I hope somebody (Marek?) joins in.

GraÅžvydas
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to