OdevAttribute: config_odev_add_attribute: replace existing values

If an attribute already exists replace its value rather than adding a
duplicate attribute with the new value to the list.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Hans de Goede 2014-02-03 15:47:35 +01:00
parent 10c64e8056
commit 350559dcdc

View File

@ -163,11 +163,14 @@ config_odev_add_attribute(struct OdevAttributes *attribs, int attrib,
{
struct OdevAttribute *oa;
oa = malloc(sizeof(struct OdevAttribute));
oa = config_odev_find_attribute(attribs, attrib);
if (!oa)
oa = calloc(1, sizeof(struct OdevAttribute));
if (!oa)
return FALSE;
oa->attrib_id = attrib;
free(oa->attrib_name);
oa->attrib_name = strdup(attrib_name);
xorg_list_append(&oa->member, &attribs->list);
return TRUE;