From 350559dcdcd8b0de57801302e385e25debcb91f1 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 3 Feb 2014 15:47:35 +0100 Subject: [PATCH] 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 Reviewed-by: Dave Airlie Reviewed-by: Peter Hutterer --- config/config.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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;