Don't check for NULL before free()
Signed-off-by: Ran Benita <ran234@gmail.com>master
parent
c41061a005
commit
6a34e4e19a
17
src/alloc.c
17
src/alloc.c
|
@ -102,8 +102,7 @@ XkbcFreeCompatMap(struct xkb_desc * xkb, unsigned which, Bool freeMap)
|
|||
bzero(&compat->groups[0], XkbNumKbdGroups * sizeof(struct xkb_mods));
|
||||
|
||||
if (which & XkbSymInterpMask) {
|
||||
if (compat->sym_interpret && (compat->size_si > 0))
|
||||
free(compat->sym_interpret);
|
||||
free(compat->sym_interpret);
|
||||
compat->size_si = compat->num_si = 0;
|
||||
compat->sym_interpret = NULL;
|
||||
}
|
||||
|
@ -221,27 +220,25 @@ XkbcFreeNames(struct xkb_desc * xkb, unsigned which, Bool freeMap)
|
|||
struct xkb_key_type * type = map->types;
|
||||
|
||||
for (i = 0; i < map->num_types; i++, type++) {
|
||||
if (type->level_names) {
|
||||
free(type->level_names);
|
||||
type->level_names = NULL;
|
||||
}
|
||||
free(type->level_names);
|
||||
type->level_names = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((which & XkbKeyNamesMask) && names->keys) {
|
||||
if (which & XkbKeyNamesMask) {
|
||||
free(names->keys);
|
||||
names->keys = NULL;
|
||||
names->num_keys = 0;
|
||||
}
|
||||
|
||||
if ((which & XkbKeyAliasesMask) && names->key_aliases) {
|
||||
if (which & XkbKeyAliasesMask) {
|
||||
free(names->key_aliases);
|
||||
names->key_aliases = NULL;
|
||||
names->num_key_aliases = 0;
|
||||
}
|
||||
|
||||
if ((which & XkbRGNamesMask) && names->radio_groups) {
|
||||
if (which & XkbRGNamesMask) {
|
||||
free(names->radio_groups);
|
||||
names->radio_groups = NULL;
|
||||
names->num_rg = 0;
|
||||
|
@ -303,7 +300,7 @@ XkbcAllocIndicatorMaps(struct xkb_desc * xkb)
|
|||
static void
|
||||
XkbcFreeIndicatorMaps(struct xkb_desc * xkb)
|
||||
{
|
||||
if (xkb && xkb->indicators) {
|
||||
if (xkb) {
|
||||
free(xkb->indicators);
|
||||
xkb->indicators = NULL;
|
||||
}
|
||||
|
|
78
src/galloc.c
78
src/galloc.c
|
@ -38,10 +38,8 @@ _XkbFreeGeomLeafElems(Bool freeAll, int first, int count,
|
|||
{
|
||||
if (freeAll || !(*elems)) {
|
||||
*num_inout = *sz_inout = 0;
|
||||
if (*elems) {
|
||||
free(*elems);
|
||||
*elems = NULL;
|
||||
}
|
||||
free(*elems);
|
||||
*elems = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -97,10 +95,8 @@ _XkbFreeGeomNonLeafElems(Bool freeAll, int first, int count,
|
|||
|
||||
if (freeAll) {
|
||||
*num_inout = *sz_inout = 0;
|
||||
if (*elems) {
|
||||
free(*elems);
|
||||
*elems = NULL;
|
||||
}
|
||||
free(*elems);
|
||||
*elems = NULL;
|
||||
}
|
||||
else if (first + count >= (*num_inout))
|
||||
*num_inout = first;
|
||||
|
@ -117,14 +113,10 @@ _XkbClearProperty(char *prop_in)
|
|||
{
|
||||
struct xkb_property * prop = (struct xkb_property *)prop_in;
|
||||
|
||||
if (prop->name) {
|
||||
free(prop->name);
|
||||
prop->name = NULL;
|
||||
}
|
||||
if (prop->value) {
|
||||
free(prop->value);
|
||||
prop->value = NULL;
|
||||
}
|
||||
free(prop->name);
|
||||
prop->name = NULL;
|
||||
free(prop->value);
|
||||
prop->value = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -151,8 +143,7 @@ _XkbClearColor(char *color_in)
|
|||
{
|
||||
struct xkb_color * color = (struct xkb_color *)color_in;
|
||||
|
||||
if (color->spec)
|
||||
free(color->spec);
|
||||
free(color->spec);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -243,21 +234,15 @@ _XkbClearDoodad(char *doodad_in)
|
|||
|
||||
switch (doodad->any.type) {
|
||||
case XkbTextDoodad:
|
||||
if (doodad->text.text) {
|
||||
free(doodad->text.text);
|
||||
doodad->text.text = NULL;
|
||||
}
|
||||
if (doodad->text.font) {
|
||||
free(doodad->text.font);
|
||||
doodad->text.font = NULL;
|
||||
}
|
||||
free(doodad->text.text);
|
||||
doodad->text.text = NULL;
|
||||
free(doodad->text.font);
|
||||
doodad->text.font = NULL;
|
||||
break;
|
||||
|
||||
case XkbLogoDoodad:
|
||||
if (doodad->logo.logo_name) {
|
||||
free(doodad->logo.logo_name);
|
||||
doodad->logo.logo_name = NULL;
|
||||
}
|
||||
free(doodad->logo.logo_name);
|
||||
doodad->logo.logo_name = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -268,12 +253,10 @@ XkbcFreeGeomDoodads(union xkb_doodad * doodads, int nDoodads, Bool freeAll)
|
|||
int i;
|
||||
union xkb_doodad * doodad;
|
||||
|
||||
if (doodads) {
|
||||
for (i = 0, doodad = doodads; i < nDoodads; i++, doodad++)
|
||||
_XkbClearDoodad((char *)doodad);
|
||||
if (freeAll)
|
||||
free(doodads);
|
||||
}
|
||||
for (i = 0, doodad = doodads; i < nDoodads && doodad; i++, doodad++)
|
||||
_XkbClearDoodad((char *)doodad);
|
||||
if (freeAll)
|
||||
free(doodads);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -283,10 +266,8 @@ _XkbClearSection(char *section_in)
|
|||
|
||||
if (section->rows)
|
||||
XkbcFreeGeomRows(section, 0, section->num_rows, True);
|
||||
if (section->doodads) {
|
||||
XkbcFreeGeomDoodads(section->doodads, section->num_doodads, True);
|
||||
section->doodads = NULL;
|
||||
}
|
||||
XkbcFreeGeomDoodads(section->doodads, section->num_doodads, True);
|
||||
section->doodads = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -329,10 +310,8 @@ XkbcFreeGeometry(struct xkb_geometry * geom, unsigned which, Bool freeMap)
|
|||
XkbcFreeGeomKeyAliases(geom, 0, geom->num_key_aliases, True);
|
||||
|
||||
if (freeMap) {
|
||||
if (geom->label_font) {
|
||||
free(geom->label_font);
|
||||
geom->label_font = NULL;
|
||||
}
|
||||
free(geom->label_font);
|
||||
geom->label_font = NULL;
|
||||
free(geom);
|
||||
}
|
||||
}
|
||||
|
@ -483,8 +462,7 @@ register struct xkb_property * prop;
|
|||
return NULL;
|
||||
for (i=0,prop=geom->properties;i<geom->num_properties;i++,prop++) {
|
||||
if ((prop->name)&&(strcmp(name,prop->name)==0)) {
|
||||
if (prop->value)
|
||||
free(prop->value);
|
||||
free(prop->value);
|
||||
prop->value= (char *)malloc(strlen(value)+1);
|
||||
if (prop->value)
|
||||
strcpy(prop->value,value);
|
||||
|
@ -644,11 +622,9 @@ struct xkb_section * section;
|
|||
if ((sz_rows>0)&&(_XkbAllocRows(section,sz_rows)!=Success))
|
||||
return NULL;
|
||||
if ((sz_doodads>0)&&(_XkbAllocDoodads(section,sz_doodads)!=Success)) {
|
||||
if (section->rows) {
|
||||
free(section->rows);
|
||||
section->rows= NULL;
|
||||
section->sz_rows= section->num_rows= 0;
|
||||
}
|
||||
free(section->rows);
|
||||
section->rows= NULL;
|
||||
section->sz_rows= section->num_rows= 0;
|
||||
return NULL;
|
||||
}
|
||||
section->name= name;
|
||||
|
|
90
src/malloc.c
90
src/malloc.c
|
@ -217,18 +217,12 @@ XkbcCopyKeyType(struct xkb_key_type * from, struct xkb_key_type * into)
|
|||
if (!from || !into)
|
||||
return BadMatch;
|
||||
|
||||
if (into->map) {
|
||||
free(into->map);
|
||||
into->map = NULL;
|
||||
}
|
||||
if (into->preserve) {
|
||||
free(into->preserve);
|
||||
into->preserve= NULL;
|
||||
}
|
||||
if (into->level_names) {
|
||||
free(into->level_names);
|
||||
into->level_names = NULL;
|
||||
}
|
||||
free(into->map);
|
||||
into->map = NULL;
|
||||
free(into->preserve);
|
||||
into->preserve= NULL;
|
||||
free(into->level_names);
|
||||
into->level_names = NULL;
|
||||
|
||||
*into = *from;
|
||||
|
||||
|
@ -397,46 +391,32 @@ XkbcFreeClientMap(struct xkb_desc * xkb, unsigned what, Bool freeMap)
|
|||
map = xkb->map;
|
||||
|
||||
if (what & XkbKeyTypesMask) {
|
||||
if (map->types) {
|
||||
if (map->num_types > 0) {
|
||||
int i;
|
||||
struct xkb_key_type * type;
|
||||
int i;
|
||||
struct xkb_key_type * type;
|
||||
|
||||
for (i = 0, type = map->types; i < map->num_types; i++, type++) {
|
||||
if (type->map) {
|
||||
free(type->map);
|
||||
type->map = NULL;
|
||||
}
|
||||
if (type->preserve) {
|
||||
free(type->preserve);
|
||||
type->preserve = NULL;
|
||||
}
|
||||
type->map_count = 0;
|
||||
if (type->level_names) {
|
||||
free(type->level_names);
|
||||
type->level_names = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(map->types);
|
||||
map->num_types = map->size_types = 0;
|
||||
map->types = NULL;
|
||||
for (i = 0, type = map->types; i < map->num_types && type; i++, type++) {
|
||||
free(type->map);
|
||||
type->map = NULL;
|
||||
free(type->preserve);
|
||||
type->preserve = NULL;
|
||||
type->map_count = 0;
|
||||
free(type->level_names);
|
||||
type->level_names = NULL;
|
||||
}
|
||||
free(map->types);
|
||||
map->num_types = map->size_types = 0;
|
||||
map->types = NULL;
|
||||
}
|
||||
|
||||
if (what & XkbKeySymsMask) {
|
||||
if (map->key_sym_map) {
|
||||
free(map->key_sym_map);
|
||||
map->key_sym_map = NULL;
|
||||
}
|
||||
if (map->syms) {
|
||||
free(map->syms);
|
||||
map->size_syms = map->num_syms = 0;
|
||||
map->syms = NULL;
|
||||
}
|
||||
free(map->key_sym_map);
|
||||
map->key_sym_map = NULL;
|
||||
free(map->syms);
|
||||
map->size_syms = map->num_syms = 0;
|
||||
map->syms = NULL;
|
||||
}
|
||||
|
||||
if ((what & XkbModifierMapMask) && map->modmap) {
|
||||
if (what & XkbModifierMapMask) {
|
||||
free(map->modmap);
|
||||
map->modmap = NULL;
|
||||
}
|
||||
|
@ -459,29 +439,25 @@ XkbcFreeServerMap(struct xkb_desc * xkb, unsigned what, Bool freeMap)
|
|||
what = XkbAllServerInfoMask;
|
||||
map = xkb->server;
|
||||
|
||||
if ((what & XkbExplicitComponentsMask) && map->explicit) {
|
||||
if (what & XkbExplicitComponentsMask) {
|
||||
free(map->explicit);
|
||||
map->explicit = NULL;
|
||||
}
|
||||
|
||||
if (what & XkbKeyActionsMask) {
|
||||
if (map->key_acts) {
|
||||
free(map->key_acts);
|
||||
map->key_acts = NULL;
|
||||
}
|
||||
if (map->acts) {
|
||||
free(map->acts);
|
||||
map->num_acts = map->size_acts = 0;
|
||||
map->acts = NULL;
|
||||
}
|
||||
free(map->key_acts);
|
||||
map->key_acts = NULL;
|
||||
free(map->acts);
|
||||
map->num_acts = map->size_acts = 0;
|
||||
map->acts = NULL;
|
||||
}
|
||||
|
||||
if ((what & XkbKeyBehaviorsMask) && map->behaviors) {
|
||||
if (what & XkbKeyBehaviorsMask) {
|
||||
free(map->behaviors);
|
||||
map->behaviors = NULL;
|
||||
}
|
||||
|
||||
if ((what & XkbVirtualModMapMask) && map->vmodmap) {
|
||||
if (what & XkbVirtualModMapMask) {
|
||||
free(map->vmodmap);
|
||||
map->vmodmap = NULL;
|
||||
}
|
||||
|
|
|
@ -578,13 +578,10 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
|
|||
static void
|
||||
FreeMultiDefs(XkbRF_MultiDefsPtr defs)
|
||||
{
|
||||
if (defs->options)
|
||||
free(defs->options);
|
||||
/* Avoid -Wcast-qual warnings. */
|
||||
if (defs->layout[1])
|
||||
/* Avoid -Wcast-qual warnings. */
|
||||
free((void *)(uintptr_t)defs->layout[1]);
|
||||
if (defs->variant[1])
|
||||
free((void *)(uintptr_t)defs->variant[1]);
|
||||
free((void *)(uintptr_t)defs->variant[1]);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -976,14 +973,11 @@ XkbRF_ClearVarDescriptions(XkbRF_DescribeVarsPtr var)
|
|||
register int i;
|
||||
|
||||
for (i=0;i<var->num_desc;i++) {
|
||||
if (var->desc[i].name)
|
||||
free(var->desc[i].name);
|
||||
if (var->desc[i].desc)
|
||||
free(var->desc[i].desc);
|
||||
free(var->desc[i].name);
|
||||
free(var->desc[i].desc);
|
||||
var->desc[i].name= var->desc[i].desc= NULL;
|
||||
}
|
||||
if (var->desc)
|
||||
free(var->desc);
|
||||
free(var->desc);
|
||||
var->desc= NULL;
|
||||
return;
|
||||
}
|
||||
|
@ -1009,34 +1003,31 @@ XkbRF_GroupPtr group;
|
|||
rules->num_extra= rules->sz_extra= 0;
|
||||
rules->extra= NULL;
|
||||
}
|
||||
if (rules->rules) {
|
||||
for (i=0,rule=rules->rules;i<rules->num_rules;i++,rule++) {
|
||||
if (rule->model) free(rule->model);
|
||||
if (rule->layout) free(rule->layout);
|
||||
if (rule->variant) free(rule->variant);
|
||||
if (rule->option) free(rule->option);
|
||||
if (rule->keycodes) free(rule->keycodes);
|
||||
if (rule->symbols) free(rule->symbols);
|
||||
if (rule->types) free(rule->types);
|
||||
if (rule->compat) free(rule->compat);
|
||||
if (rule->geometry) free(rule->geometry);
|
||||
if (rule->keymap) free(rule->keymap);
|
||||
bzero((char *)rule,sizeof(XkbRF_RuleRec));
|
||||
}
|
||||
free(rules->rules);
|
||||
rules->num_rules= rules->sz_rules= 0;
|
||||
rules->rules= NULL;
|
||||
for (i=0, rule = rules->rules; i < rules->num_rules && rules; i++, rule++) {
|
||||
free(rule->model);
|
||||
free(rule->layout);
|
||||
free(rule->variant);
|
||||
free(rule->option);
|
||||
free(rule->keycodes);
|
||||
free(rule->symbols);
|
||||
free(rule->types);
|
||||
free(rule->compat);
|
||||
free(rule->geometry);
|
||||
free(rule->keymap);
|
||||
bzero((char *)rule,sizeof(XkbRF_RuleRec));
|
||||
}
|
||||
free(rules->rules);
|
||||
rules->num_rules= rules->sz_rules= 0;
|
||||
rules->rules= NULL;
|
||||
|
||||
if (rules->groups) {
|
||||
for (i=0, group=rules->groups;i<rules->num_groups;i++,group++) {
|
||||
if (group->name) free(group->name);
|
||||
if (group->words) free(group->words);
|
||||
}
|
||||
free(rules->groups);
|
||||
rules->num_groups= 0;
|
||||
rules->groups= NULL;
|
||||
for (i=0, group = rules->groups; i < rules->num_groups && group; i++, group++) {
|
||||
free(group->name);
|
||||
free(group->words);
|
||||
}
|
||||
free(rules->groups);
|
||||
rules->num_groups= 0;
|
||||
rules->groups= NULL;
|
||||
|
||||
if (freeRules)
|
||||
free(rules);
|
||||
return;
|
||||
|
|
|
@ -137,8 +137,7 @@ ClearCompatInfo(CompatInfo * info, struct xkb_desc * xkb)
|
|||
{
|
||||
register int i;
|
||||
|
||||
if (info->name != NULL)
|
||||
free(info->name);
|
||||
free(info->name);
|
||||
info->name = NULL;
|
||||
info->dflt.defs.defined = 0;
|
||||
info->dflt.defs.merge = MergeAugment;
|
||||
|
@ -426,8 +425,7 @@ HandleIncludeCompatMap(IncludeStmt * stmt,
|
|||
(*hndlr) (rtrn, xkb, MergeOverride, &included);
|
||||
if (stmt->stmt != NULL)
|
||||
{
|
||||
if (included.name != NULL)
|
||||
free(included.name);
|
||||
free(included.name);
|
||||
included.name = stmt->stmt;
|
||||
stmt->stmt = NULL;
|
||||
}
|
||||
|
@ -857,7 +855,6 @@ CompileCompatMap(XkbFile *file, struct xkb_desc * xkb, unsigned merge,
|
|||
ClearCompatInfo(&info, xkb);
|
||||
return True;
|
||||
}
|
||||
if (info.interps != NULL)
|
||||
free(info.interps);
|
||||
free(info.interps);
|
||||
return False;
|
||||
}
|
||||
|
|
|
@ -292,10 +292,8 @@ FreeProperties(PropertyInfo * pi, GeometryInfo * info)
|
|||
}
|
||||
for (tmp = pi; tmp != NULL; tmp = next)
|
||||
{
|
||||
if (tmp->name)
|
||||
free(tmp->name);
|
||||
if (tmp->value)
|
||||
free(tmp->value);
|
||||
free(tmp->name);
|
||||
free(tmp->value);
|
||||
tmp->name = tmp->value = NULL;
|
||||
next = (PropertyInfo *) tmp->defs.next;
|
||||
free(tmp);
|
||||
|
@ -674,8 +672,7 @@ InitGeometryInfo(GeometryInfo * info, unsigned fileID, unsigned merge)
|
|||
static void
|
||||
ClearGeometryInfo(GeometryInfo * info)
|
||||
{
|
||||
if (info->name)
|
||||
free(info->name);
|
||||
free(info->name);
|
||||
info->name = NULL;
|
||||
if (info->props)
|
||||
FreeProperties(info->props, info);
|
||||
|
@ -748,8 +745,7 @@ AddProperty(GeometryInfo * info, PropertyInfo * new)
|
|||
ACTION("Ignoring \"%s\", using \"%s\"\n", old->value,
|
||||
new->value);
|
||||
}
|
||||
if (old->value)
|
||||
free(old->value);
|
||||
free(old->value);
|
||||
old->value = _XkbDupString(new->value);
|
||||
return True;
|
||||
}
|
||||
|
@ -1344,8 +1340,7 @@ HandleIncludeGeometry(IncludeStmt * stmt, struct xkb_desc * xkb, GeometryInfo *
|
|||
(*hndlr) (rtrn, xkb, MergeOverride, &included);
|
||||
if (stmt->stmt != NULL)
|
||||
{
|
||||
if (included.name != NULL)
|
||||
free(included.name);
|
||||
free(included.name);
|
||||
included.name = stmt->stmt;
|
||||
stmt->stmt = NULL;
|
||||
}
|
||||
|
|
|
@ -320,8 +320,7 @@ AddIndicatorName(KeyNamesInfo * info, IndicatorNameInfo * new)
|
|||
static void
|
||||
ClearKeyNamesInfo(KeyNamesInfo * info)
|
||||
{
|
||||
if (info->name != NULL)
|
||||
free(info->name);
|
||||
free(info->name);
|
||||
info->name = NULL;
|
||||
info->computedMax = info->explicitMax = info->explicitMin = 0;
|
||||
info->computedMin = XKB_KEYCODE_MAX;
|
||||
|
@ -578,8 +577,7 @@ HandleIncludeKeycodes(IncludeStmt * stmt, struct xkb_desc * xkb, KeyNamesInfo *
|
|||
HandleKeycodesFile(rtrn, xkb, MergeOverride, &included);
|
||||
if (stmt->stmt != NULL)
|
||||
{
|
||||
if (included.name != NULL)
|
||||
free(included.name);
|
||||
free(included.name);
|
||||
included.name = stmt->stmt;
|
||||
stmt->stmt = NULL;
|
||||
}
|
||||
|
|
|
@ -179,16 +179,10 @@ InitKeyTypesInfo(KeyTypesInfo * info, struct xkb_desc * xkb, KeyTypesInfo * from
|
|||
static void
|
||||
FreeKeyTypeInfo(KeyTypeInfo * type)
|
||||
{
|
||||
if (type->entries != NULL)
|
||||
{
|
||||
free(type->entries);
|
||||
type->entries = NULL;
|
||||
}
|
||||
if (type->lvlNames != NULL)
|
||||
{
|
||||
free(type->lvlNames);
|
||||
type->lvlNames = NULL;
|
||||
}
|
||||
free(type->entries);
|
||||
type->entries = NULL;
|
||||
free(type->lvlNames);
|
||||
type->lvlNames = NULL;
|
||||
if (type->preserve != NULL)
|
||||
{
|
||||
ClearCommonInfo(&type->preserve->defs);
|
||||
|
@ -200,8 +194,7 @@ FreeKeyTypeInfo(KeyTypeInfo * type)
|
|||
static void
|
||||
FreeKeyTypesInfo(KeyTypesInfo * info)
|
||||
{
|
||||
if (info->name)
|
||||
free(info->name);
|
||||
free(info->name);
|
||||
info->name = NULL;
|
||||
if (info->types)
|
||||
{
|
||||
|
@ -397,8 +390,7 @@ HandleIncludeKeyTypes(IncludeStmt * stmt,
|
|||
(*hndlr) (rtrn, xkb, newMerge, &included);
|
||||
if (stmt->stmt != NULL)
|
||||
{
|
||||
if (included.name != NULL)
|
||||
free(included.name);
|
||||
free(included.name);
|
||||
included.name = stmt->stmt;
|
||||
stmt->stmt = NULL;
|
||||
}
|
||||
|
|
|
@ -540,10 +540,8 @@ OverlayKeyCreate(char *under, char *over)
|
|||
key->common.stmtType = StmtOverlayKeyDef;
|
||||
strncpy(key->over, over, XkbKeyNameLength);
|
||||
strncpy(key->under, under, XkbKeyNameLength);
|
||||
if (over)
|
||||
free(over);
|
||||
if (under)
|
||||
free(under);
|
||||
free(over);
|
||||
free(under);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
@ -694,7 +692,7 @@ IncludeCreate(char *str, unsigned merge)
|
|||
}
|
||||
if (first)
|
||||
first->stmt = stmt;
|
||||
else if (stmt)
|
||||
else
|
||||
free(stmt);
|
||||
return first;
|
||||
BAIL:
|
||||
|
@ -703,20 +701,15 @@ IncludeCreate(char *str, unsigned merge)
|
|||
while (first)
|
||||
{
|
||||
incl = first->next;
|
||||
if (first->file)
|
||||
free(first->file);
|
||||
if (first->map)
|
||||
free(first->map);
|
||||
if (first->modifier)
|
||||
free(first->modifier);
|
||||
if (first->path)
|
||||
free(first->path);
|
||||
free(first->file);
|
||||
free(first->map);
|
||||
free(first->modifier);
|
||||
free(first->path);
|
||||
first->file = first->map = first->path = NULL;
|
||||
free(first);
|
||||
first = incl;
|
||||
}
|
||||
if (stmt)
|
||||
free(stmt);
|
||||
free(stmt);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -130,11 +130,9 @@ FreeKeyInfo(KeyInfo * info)
|
|||
{
|
||||
info->numLevels[i] = 0;
|
||||
info->types[i] = None;
|
||||
if (info->syms[i] != NULL)
|
||||
free(info->syms[i]);
|
||||
free(info->syms[i]);
|
||||
info->syms[i] = NULL;
|
||||
if (info->acts[i] != NULL)
|
||||
free(info->acts[i]);
|
||||
free(info->acts[i]);
|
||||
info->acts[i] = NULL;
|
||||
}
|
||||
info->dfltType = None;
|
||||
|
@ -270,28 +268,17 @@ FreeSymbolsInfo(SymbolsInfo * info)
|
|||
{
|
||||
register int i;
|
||||
|
||||
if (info->name)
|
||||
free(info->name);
|
||||
info->name = NULL;
|
||||
free(info->name);
|
||||
if (info->keys)
|
||||
{
|
||||
for (i = 0; i < info->nKeys; i++)
|
||||
{
|
||||
FreeKeyInfo(&info->keys[i]);
|
||||
}
|
||||
free(info->keys);
|
||||
info->keys = NULL;
|
||||
}
|
||||
if (info->modMap)
|
||||
{
|
||||
ClearCommonInfo(&info->modMap->defs);
|
||||
info->modMap = NULL;
|
||||
}
|
||||
if (info->aliases)
|
||||
{
|
||||
ClearAliases(&info->aliases);
|
||||
info->aliases = NULL;
|
||||
}
|
||||
bzero((char *) info, sizeof(SymbolsInfo));
|
||||
return;
|
||||
}
|
||||
|
@ -457,13 +444,13 @@ MergeKeyGroups(SymbolsInfo * info,
|
|||
}
|
||||
}
|
||||
}
|
||||
if ((into->syms[group] != NULL) && (resultSyms != into->syms[group]))
|
||||
if (resultSyms != into->syms[group])
|
||||
free(into->syms[group]);
|
||||
if ((from->syms[group] != NULL) && (resultSyms != from->syms[group]))
|
||||
if (resultSyms != from->syms[group])
|
||||
free(from->syms[group]);
|
||||
if ((into->acts[group] != NULL) && (resultActs != into->acts[group]))
|
||||
if (resultActs != into->acts[group])
|
||||
free(into->acts[group]);
|
||||
if ((from->acts[group] != NULL) && (resultActs != from->acts[group]))
|
||||
if (resultActs != from->acts[group])
|
||||
free(from->acts[group]);
|
||||
into->numLevels[group] = resultWidth;
|
||||
into->syms[group] = resultSyms;
|
||||
|
@ -490,10 +477,8 @@ MergeKeys(SymbolsInfo * info, KeyInfo * into, KeyInfo * from)
|
|||
{
|
||||
if (into->numLevels[i] != 0)
|
||||
{
|
||||
if (into->syms[i])
|
||||
free(into->syms[i]);
|
||||
if (into->acts[i])
|
||||
free(into->acts[i]);
|
||||
free(into->syms[i]);
|
||||
free(into->acts[i]);
|
||||
}
|
||||
}
|
||||
*into = *from;
|
||||
|
@ -801,8 +786,7 @@ HandleIncludeSymbols(IncludeStmt * stmt,
|
|||
(*hndlr) (rtrn, xkb, MergeOverride, &included);
|
||||
if (stmt->stmt != NULL)
|
||||
{
|
||||
if (included.name != NULL)
|
||||
free(included.name);
|
||||
free(included.name);
|
||||
included.name = stmt->stmt;
|
||||
stmt->stmt = NULL;
|
||||
}
|
||||
|
@ -1507,11 +1491,9 @@ SetExplicitGroup(SymbolsInfo * info, KeyInfo * key)
|
|||
for (i = 1; i < XkbNumKbdGroups; i++)
|
||||
{
|
||||
key->numLevels[i] = 0;
|
||||
if (key->syms[i] != NULL)
|
||||
free(key->syms[i]);
|
||||
free(key->syms[i]);
|
||||
key->syms[i] = (uint32_t *) NULL;
|
||||
if (key->acts[i] != NULL)
|
||||
free(key->acts[i]);
|
||||
free(key->acts[i]);
|
||||
key->acts[i] = (union xkb_action *) NULL;
|
||||
key->types[i] = (uint32_t) 0;
|
||||
}
|
||||
|
@ -1873,11 +1855,9 @@ PrepareKeyDef(KeyInfo * key)
|
|||
for (i = lastGroup; i > 0; i--)
|
||||
{
|
||||
key->numLevels[i] = 0;
|
||||
if (key->syms[i] != NULL)
|
||||
free(key->syms[i]);
|
||||
free(key->syms[i]);
|
||||
key->syms[i] = (uint32_t *) NULL;
|
||||
if (key->acts[i] != NULL)
|
||||
free(key->acts[i]);
|
||||
free(key->acts[i]);
|
||||
key->acts[i] = (union xkb_action *) NULL;
|
||||
key->types[i] = (uint32_t) 0;
|
||||
}
|
||||
|
|
|
@ -332,8 +332,7 @@ KeyNameDecl : KeyName EQUALS KeyCode SEMI
|
|||
KeycodeDef *def;
|
||||
|
||||
def= KeycodeCreate($1,$3);
|
||||
if ($1)
|
||||
free($1);
|
||||
free($1);
|
||||
$$= def;
|
||||
}
|
||||
;
|
||||
|
@ -342,8 +341,8 @@ KeyAliasDecl : ALIAS KeyName EQUALS KeyName SEMI
|
|||
{
|
||||
KeyAliasDef *def;
|
||||
def= KeyAliasCreate($2,$4);
|
||||
if ($2) free($2);
|
||||
if ($4) free($4);
|
||||
free($2);
|
||||
free($4);
|
||||
$$= def;
|
||||
}
|
||||
;
|
||||
|
|
|
@ -199,8 +199,7 @@ yyerror(const char *msg)
|
|||
void setScanState(const char *file, int lineno)
|
||||
{
|
||||
yylineno = 1;
|
||||
if (scanFile)
|
||||
free(scanFile);
|
||||
free(scanFile);
|
||||
scanFile = strdup(file);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue