xkb: Replace malloc(strlen) + strcpy with strdup
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
parent
682865c460
commit
0f9c6f2f82
|
@ -647,9 +647,7 @@ register XkbPropertyPtr prop;
|
||||||
for (i=0,prop=geom->properties;i<geom->num_properties;i++,prop++) {
|
for (i=0,prop=geom->properties;i<geom->num_properties;i++,prop++) {
|
||||||
if ((prop->name)&&(strcmp(name,prop->name)==0)) {
|
if ((prop->name)&&(strcmp(name,prop->name)==0)) {
|
||||||
free(prop->value);
|
free(prop->value);
|
||||||
prop->value= malloc(strlen(value)+1);
|
prop->value= strdup(value);
|
||||||
if (prop->value)
|
|
||||||
strcpy(prop->value,value);
|
|
||||||
return prop;
|
return prop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -658,17 +656,15 @@ register XkbPropertyPtr prop;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
prop= &geom->properties[geom->num_properties];
|
prop= &geom->properties[geom->num_properties];
|
||||||
prop->name= malloc(strlen(name)+1);
|
prop->name= strdup(name);
|
||||||
if (!prop->name)
|
if (!prop->name)
|
||||||
return NULL;
|
return NULL;
|
||||||
strcpy(prop->name,name);
|
prop->value= strdup(value);
|
||||||
prop->value= malloc(strlen(value)+1);
|
|
||||||
if (!prop->value) {
|
if (!prop->value) {
|
||||||
free(prop->name);
|
free(prop->name);
|
||||||
prop->name= NULL;
|
prop->name= NULL;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
strcpy(prop->value,value);
|
|
||||||
geom->num_properties++;
|
geom->num_properties++;
|
||||||
return prop;
|
return prop;
|
||||||
}
|
}
|
||||||
|
@ -720,10 +716,9 @@ register XkbColorPtr color;
|
||||||
}
|
}
|
||||||
color= &geom->colors[geom->num_colors];
|
color= &geom->colors[geom->num_colors];
|
||||||
color->pixel= pixel;
|
color->pixel= pixel;
|
||||||
color->spec= malloc(strlen(spec)+1);
|
color->spec= strdup(spec);
|
||||||
if (!color->spec)
|
if (!color->spec)
|
||||||
return NULL;
|
return NULL;
|
||||||
strcpy(color->spec,spec);
|
|
||||||
geom->num_colors++;
|
geom->num_colors++;
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user