Free XkbFile's when no longer needed

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2012-03-02 14:49:36 +02:00
parent c357a11aa6
commit 889a299e3b
9 changed files with 44 additions and 20 deletions

View File

@ -426,6 +426,7 @@ HandleIncludeCompatMap(IncludeStmt * stmt,
included.name = stmt->stmt; included.name = stmt->stmt;
stmt->stmt = NULL; stmt->stmt = NULL;
} }
FreeXKBFile(rtrn);
} }
else else
{ {
@ -459,6 +460,7 @@ HandleIncludeCompatMap(IncludeStmt * stmt,
(*hndlr) (rtrn, xkb, MergeOverride, &next_incl); (*hndlr) (rtrn, xkb, MergeOverride, &next_incl);
MergeIncludedCompatMaps(&included, &next_incl, op); MergeIncludedCompatMaps(&included, &next_incl, op);
ClearCompatInfo(&next_incl, xkb); ClearCompatInfo(&next_incl, xkb);
FreeXKBFile(rtrn);
} }
else else
{ {

View File

@ -35,6 +35,7 @@
#include "action.h" #include "action.h"
#include "keycodes.h" #include "keycodes.h"
#include "alias.h" #include "alias.h"
#include "parseutils.h"
#define DFLT_FONT "helvetica" #define DFLT_FONT "helvetica"
#define DFLT_SLANT "r" #define DFLT_SLANT "r"
@ -1323,6 +1324,7 @@ HandleIncludeGeometry(IncludeStmt * stmt, struct xkb_desc * xkb, GeometryInfo *
included.name = stmt->stmt; included.name = stmt->stmt;
stmt->stmt = NULL; stmt->stmt = NULL;
} }
FreeXKBFile(rtrn);
} }
else else
{ {
@ -1353,6 +1355,7 @@ HandleIncludeGeometry(IncludeStmt * stmt, struct xkb_desc * xkb, GeometryInfo *
(*hndlr) (rtrn, xkb, MergeOverride, &next_incl); (*hndlr) (rtrn, xkb, MergeOverride, &next_incl);
MergeIncludedGeometry(&included, &next_incl, op); MergeIncludedGeometry(&included, &next_incl, op);
ClearGeometryInfo(&next_incl); ClearGeometryInfo(&next_incl);
FreeXKBFile(rtrn);
} }
else else
{ {

View File

@ -31,6 +31,7 @@
#include "keycodes.h" #include "keycodes.h"
#include "misc.h" #include "misc.h"
#include "alias.h" #include "alias.h"
#include "parseutils.h"
const char * const char *
longText(unsigned long val) longText(unsigned long val)
@ -575,6 +576,7 @@ HandleIncludeKeycodes(IncludeStmt * stmt, struct xkb_desc * xkb, KeyNamesInfo *
included.name = stmt->stmt; included.name = stmt->stmt;
stmt->stmt = NULL; stmt->stmt = NULL;
} }
FreeXKBFile(rtrn);
} }
else else
{ {
@ -602,6 +604,7 @@ HandleIncludeKeycodes(IncludeStmt * stmt, struct xkb_desc * xkb, KeyNamesInfo *
HandleKeycodesFile(rtrn, xkb, MergeOverride, &next_incl); HandleKeycodesFile(rtrn, xkb, MergeOverride, &next_incl);
MergeIncludedKeycodes(&included, &next_incl, op); MergeIncludedKeycodes(&included, &next_incl, op);
ClearKeyNamesInfo(&next_incl); ClearKeyNamesInfo(&next_incl);
FreeXKBFile(rtrn);
} }
else else
{ {

View File

@ -83,7 +83,10 @@ CompileKeymap(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
/* Check for duplicate entries in the input file */ /* Check for duplicate entries in the input file */
while ((file) && (ok)) while ((file) && (ok))
{ {
file->topName = mainName; if (file->topName != mainName) {
free(file->topName);
file->topName = strdup(mainName);
}
if ((have & (1 << file->type)) != 0) if ((have & (1 << file->type)) != 0)
{ {
ERROR("More than one %s section in a %s file\n", ERROR("More than one %s section in a %s file\n",

View File

@ -31,6 +31,7 @@
#include "vmod.h" #include "vmod.h"
#include "action.h" #include "action.h"
#include "misc.h" #include "misc.h"
#include "parseutils.h"
typedef struct _PreserveInfo typedef struct _PreserveInfo
{ {
@ -390,6 +391,7 @@ HandleIncludeKeyTypes(IncludeStmt * stmt,
included.name = stmt->stmt; included.name = stmt->stmt;
stmt->stmt = NULL; stmt->stmt = NULL;
} }
FreeXKBFile(rtrn);
} }
else else
{ {
@ -418,6 +420,7 @@ HandleIncludeKeyTypes(IncludeStmt * stmt,
(*hndlr) (rtrn, xkb, op, &next_incl); (*hndlr) (rtrn, xkb, op, &next_incl);
MergeIncludedKeyTypes(&included, &next_incl, op, xkb); MergeIncludedKeyTypes(&included, &next_incl, op, xkb);
FreeKeyTypesInfo(&next_incl); FreeKeyTypesInfo(&next_incl);
FreeXKBFile(rtrn);
} }
else else
{ {

View File

@ -53,7 +53,7 @@ ProcessIncludeFile(IncludeStmt * stmt,
XkbFile ** file_rtrn, unsigned *merge_rtrn) XkbFile ** file_rtrn, unsigned *merge_rtrn)
{ {
FILE *file; FILE *file;
XkbFile *rtrn, *mapToUse; XkbFile *rtrn, *mapToUse, *next;
char oldFile[1024] = {0}; char oldFile[1024] = {0};
int oldLine = lineNum; int oldLine = lineNum;
@ -85,10 +85,21 @@ ProcessIncludeFile(IncludeStmt * stmt,
mapToUse = rtrn; mapToUse = rtrn;
if (stmt->map != NULL) if (stmt->map != NULL)
{ {
while ((mapToUse) && ((!uStringEqual(mapToUse->name, stmt->map)) || while (mapToUse)
(mapToUse->type != file_type)))
{ {
mapToUse = (XkbFile *) mapToUse->common.next; next = (XkbFile *)mapToUse->common.next;
mapToUse->common.next = NULL;
if (uStringEqual(mapToUse->name, stmt->map) &&
mapToUse->type == file_type)
{
FreeXKBFile(next);
break;
}
else
{
FreeXKBFile(mapToUse);
}
mapToUse = next;
} }
if (!mapToUse) if (!mapToUse)
{ {

View File

@ -633,6 +633,9 @@ LookupKeysym(char *str, uint32_t * sym_rtrn)
return 0; return 0;
} }
static void
FreeInclude(IncludeStmt *incl);
IncludeStmt * IncludeStmt *
IncludeCreate(char *str, unsigned merge) IncludeCreate(char *str, unsigned merge)
{ {
@ -696,20 +699,11 @@ IncludeCreate(char *str, unsigned merge)
else else
free(stmt); free(stmt);
return first; return first;
BAIL:
BAIL:
ERROR("Illegal include statement \"%s\"\n", stmt); ERROR("Illegal include statement \"%s\"\n", stmt);
ACTION("Ignored\n"); ACTION("Ignored\n");
while (first) FreeInclude(first);
{
incl = first->next;
free(first->file);
free(first->map);
free(first->modifier);
free(first->path);
first->file = first->map = first->path = NULL;
free(first);
first = incl;
}
free(stmt); free(stmt);
return NULL; return NULL;
} }
@ -873,6 +867,7 @@ FreeStmt(ParseCommon *stmt)
{ {
case StmtInclude: case StmtInclude:
FreeInclude((IncludeStmt *)stmt); FreeInclude((IncludeStmt *)stmt);
/* stmt is already free'd here. */
stmt = NULL; stmt = NULL;
break; break;
case StmtExpr: case StmtExpr:
@ -967,7 +962,7 @@ FreeXKBFile(XkbFile *file)
} }
free(file->name); free(file->name);
/* free(file->topName); */ free(file->topName);
free(file); free(file);
file = next; file = next;
} }

View File

@ -777,6 +777,7 @@ HandleIncludeSymbols(IncludeStmt * stmt,
included.name = stmt->stmt; included.name = stmt->stmt;
stmt->stmt = NULL; stmt->stmt = NULL;
} }
FreeXKBFile(rtrn);
} }
else else
{ {
@ -813,6 +814,7 @@ HandleIncludeSymbols(IncludeStmt * stmt,
(*hndlr) (rtrn, xkb, MergeOverride, &next_incl); (*hndlr) (rtrn, xkb, MergeOverride, &next_incl);
MergeIncludedSymbols(&included, &next_incl, op, xkb); MergeIncludedSymbols(&included, &next_incl, op, xkb);
FreeSymbolsInfo(&next_incl); FreeSymbolsInfo(&next_incl);
FreeXKBFile(rtrn);
} }
else else
{ {

View File

@ -225,11 +225,12 @@ xkb_compile_keymap_from_components(const struct xkb_component_names * ktcsg)
goto unwind_xkb; goto unwind_xkb;
} }
FreeXKBFile(file);
return xkb; return xkb;
unwind_xkb: unwind_xkb:
XkbcFreeKeyboard(xkb); XkbcFreeKeyboard(xkb);
unwind_file: unwind_file:
/* XXX: here's where we would free the XkbFile */ FreeXKBFile(file);
fail: fail:
return NULL; return NULL;
} }
@ -265,11 +266,12 @@ compile_keymap(XkbFile *file, const char *mapName)
goto unwind_xkb; goto unwind_xkb;
} }
FreeXKBFile(file);
return xkb; return xkb;
unwind_xkb: unwind_xkb:
XkbcFreeKeyboard(xkb); XkbcFreeKeyboard(xkb);
unwind_file: unwind_file:
/* XXX: here's where we would free the XkbFile */ FreeXKBFile(file);
return NULL; return NULL;
} }