[virglrenderer-devel] ?==?utf-8?q? How to iterate util_hash_table

Alexandros Frantzis alexandros.frantzis at collabora.com
Mon Jun 22 06:31:25 UTC 2020


On Sunday, June 21, 2020 04:15 BST, Zhu Yijun <lovemrd at gmail.com> wrote: 
 
> Hi all,
>   I want to walk through each item in util_hash_table in order to
> support migration, such as sub_ctx's object table. Currently, my way
> is to maintain an extra object_handle_list member in
> vrend_sub_context, and then get all items by vrend_object_lookup, as
> below:
> 
>   struct vrend_object_handle *obj;
>   LIST_FOR_EACH_ENTRY(obj, &sub->object_handle_list, head) {
> state = vrend_object_lookup(sub->object_hash, obj->handle, VIRGL_OBJECT_DSA);
>   }
> 
>   It looks ugly, is there a simple method to iterate util_hash_table? Thanks.
> 
> Yijun

Hi Yijun,

You can use the util_hash_table_foreach() function, although that requires a callback
function, so iteration is not inline like in the case of a list.

HTH,
Alexandros



More information about the virglrenderer-devel mailing list