summaryrefslogtreecommitdiff
path: root/config/config.c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2014-02-03 15:47:35 +0100
committerHans de Goede <hdegoede@redhat.com>2014-03-03 08:13:55 +0100
commit350559dcdcd8b0de57801302e385e25debcb91f1 (patch)
tree99810a411f9c58ef05d58ef0bdbba73d9286a6be /config/config.c
parent10c64e80569bbd35e97916a067f553cab27454b5 (diff)
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>
Diffstat (limited to 'config/config.c')
-rw-r--r--config/config.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/config/config.c b/config/config.c
index 088bd5ac2..776f1d850 100644
--- a/config/config.c
+++ b/config/config.c
@@ -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;