[PATCH v4 15/15] lib/igt_device_scan: reuse igt hash
Zbigniew Kempczyński
zbigniew.kempczynski at intel.com
Fri May 16 05:07:12 UTC 2025
On Thu, May 15, 2025 at 08:23:33PM +0200, Badrappan, Jeevaka wrote:
> > #include <libudev.h>
> > #ifdef __linux__
> > #include <linux/limits.h>
> > @@ -224,8 +224,8 @@ struct igt_device {
> > /* Point to vendor spec if can be found */
> >
> > /* Properties / sysattrs rewriten from udev lists */
> > - GHashTable *props_ht;
> > - GHashTable *attrs_ht;
> > + struct igt_map *props_map;
> > + struct igt_map *attrs_map;
> >
> > /* Most usable variables from udev device */
> > char *subsystem;
> > @@ -464,6 +464,11 @@ static bool is_on_blacklist(const char *what)
> >
> > }
> >
> > +static int key_equals(const void *key1, const void *key2)
> > +{
> > + return strcmp((char *)key1, (char *)key2) == 0;
> > +}
> > +
> > static struct igt_device *igt_device_new(void)
> > {
> > struct igt_device *dev;
> > @@ -472,14 +477,14 @@ static struct igt_device *igt_device_new(void)
> > if (!dev)
> > return NULL;
> >
> > - dev->attrs_ht = g_hash_table_new_full(g_str_hash, g_str_equal,
> > - free, free);
> > - dev->props_ht = g_hash_table_new_full(g_str_hash, g_str_equal,
> > - free, free);
> > + dev->attrs_map = igt_map_create(igt_map_hash_32, key_equals);
> > + dev->props_map = igt_map_create(igt_map_hash_32, key_equals);
> >
> > - if (dev->attrs_ht && dev->props_ht)
> > + if (dev->attrs_map && dev->props_map)
> > return dev;
> >
> > + igt_map_destroy(dev->attrs_map, NULL);
> > + igt_map_destroy(dev->props_map, NULL);
>
> > What for are you freeing the map here?
> map and also device is freed if creation of attrs_map or props_map fails.
Ok, now I get your point. Makes sense.
--
Zbigniew
> Thanks and Regards,
> Jeevaka
More information about the igt-dev
mailing list