Remove unneeded freeing mechanisms
Signed-off-by: Ran Benita <ran234@gmail.com>master
parent
c7bf368780
commit
a64e970809
71
src/alloc.c
71
src/alloc.c
|
@ -87,7 +87,7 @@ XkbcAllocCompatMap(struct xkb_desc * xkb, unsigned which, unsigned nSI)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
XkbcFreeCompatMap(struct xkb_desc * xkb, unsigned which, Bool freeMap)
|
XkbcFreeCompatMap(struct xkb_desc * xkb)
|
||||||
{
|
{
|
||||||
struct xkb_compat_map * compat;
|
struct xkb_compat_map * compat;
|
||||||
|
|
||||||
|
@ -95,24 +95,11 @@ XkbcFreeCompatMap(struct xkb_desc * xkb, unsigned which, Bool freeMap)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
compat = xkb->compat;
|
compat = xkb->compat;
|
||||||
if (freeMap)
|
|
||||||
which = XkbAllCompatMask;
|
|
||||||
|
|
||||||
if (which & XkbGroupCompatMask)
|
|
||||||
memset(&compat->groups[0], 0,
|
|
||||||
XkbNumKbdGroups * sizeof(struct xkb_mods));
|
|
||||||
|
|
||||||
if (which & XkbSymInterpMask) {
|
|
||||||
free(compat->sym_interpret);
|
free(compat->sym_interpret);
|
||||||
compat->size_si = compat->num_si = 0;
|
|
||||||
compat->sym_interpret = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (freeMap) {
|
|
||||||
free(compat);
|
free(compat);
|
||||||
xkb->compat = NULL;
|
xkb->compat = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
XkbcAllocNames(struct xkb_desc * xkb, unsigned which, int nTotalRG, int nTotalAliases)
|
XkbcAllocNames(struct xkb_desc * xkb, unsigned which, int nTotalRG, int nTotalAliases)
|
||||||
|
@ -202,19 +189,16 @@ XkbcAllocNames(struct xkb_desc * xkb, unsigned which, int nTotalRG, int nTotalAl
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
XkbcFreeNames(struct xkb_desc * xkb, unsigned which, Bool freeMap)
|
XkbcFreeNames(struct xkb_desc * xkb)
|
||||||
{
|
{
|
||||||
struct xkb_names * names;
|
struct xkb_names * names;
|
||||||
|
struct xkb_client_map * map;
|
||||||
|
|
||||||
if (!xkb || !xkb->names)
|
if (!xkb || !xkb->names)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
names = xkb->names;
|
names = xkb->names;
|
||||||
if (freeMap)
|
map = xkb->map;
|
||||||
which = XkbAllNamesMask;
|
|
||||||
|
|
||||||
if (which & XkbKTLevelNamesMask) {
|
|
||||||
struct xkb_client_map * map = xkb->map;
|
|
||||||
|
|
||||||
if (map && map->types) {
|
if (map && map->types) {
|
||||||
int i;
|
int i;
|
||||||
|
@ -225,31 +209,13 @@ XkbcFreeNames(struct xkb_desc * xkb, unsigned which, Bool freeMap)
|
||||||
type->level_names = NULL;
|
type->level_names = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (which & XkbKeyNamesMask) {
|
|
||||||
free(names->keys);
|
free(names->keys);
|
||||||
names->keys = NULL;
|
|
||||||
names->num_keys = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (which & XkbKeyAliasesMask) {
|
|
||||||
free(names->key_aliases);
|
free(names->key_aliases);
|
||||||
names->key_aliases = NULL;
|
|
||||||
names->num_key_aliases = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (which & XkbRGNamesMask) {
|
|
||||||
free(names->radio_groups);
|
free(names->radio_groups);
|
||||||
names->radio_groups = NULL;
|
|
||||||
names->num_rg = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (freeMap) {
|
|
||||||
free(names);
|
free(names);
|
||||||
xkb->names = NULL;
|
xkb->names = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
XkbcAllocControls(struct xkb_desc * xkb, unsigned which)
|
XkbcAllocControls(struct xkb_desc * xkb, unsigned which)
|
||||||
|
@ -274,9 +240,9 @@ XkbcAllocControls(struct xkb_desc * xkb, unsigned which)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
XkbcFreeControls(struct xkb_desc * xkb, unsigned which, Bool freeMap)
|
XkbcFreeControls(struct xkb_desc * xkb)
|
||||||
{
|
{
|
||||||
if (freeMap && xkb && xkb->ctrls) {
|
if (xkb && xkb->ctrls) {
|
||||||
free(xkb->ctrls->per_key_repeat);
|
free(xkb->ctrls->per_key_repeat);
|
||||||
free(xkb->ctrls);
|
free(xkb->ctrls);
|
||||||
xkb->ctrls = NULL;
|
xkb->ctrls = NULL;
|
||||||
|
@ -319,28 +285,17 @@ XkbcAllocKeyboard(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
XkbcFreeKeyboard(struct xkb_desc * xkb, unsigned which, Bool freeAll)
|
XkbcFreeKeyboard(struct xkb_desc * xkb)
|
||||||
{
|
{
|
||||||
if (!xkb)
|
if (!xkb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (freeAll)
|
XkbcFreeClientMap(xkb);
|
||||||
which = XkbAllComponentsMask;
|
XkbcFreeServerMap(xkb);
|
||||||
|
XkbcFreeCompatMap(xkb);
|
||||||
if (which & XkbClientMapMask)
|
|
||||||
XkbcFreeClientMap(xkb, XkbAllClientInfoMask, True);
|
|
||||||
if (which & XkbServerMapMask)
|
|
||||||
XkbcFreeServerMap(xkb, XkbAllServerInfoMask, True);
|
|
||||||
if (which & XkbCompatMapMask)
|
|
||||||
XkbcFreeCompatMap(xkb, XkbAllCompatMask, True);
|
|
||||||
if (which & XkbIndicatorMapMask)
|
|
||||||
XkbcFreeIndicatorMaps(xkb);
|
XkbcFreeIndicatorMaps(xkb);
|
||||||
if (which & XkbNamesMask)
|
XkbcFreeNames(xkb);
|
||||||
XkbcFreeNames(xkb, XkbAllNamesMask, True);
|
XkbcFreeGeometry(xkb);
|
||||||
if ((which & XkbGeometryMask) && xkb->geom)
|
XkbcFreeControls(xkb);
|
||||||
XkbcFreeGeometry(xkb->geom, XkbGeomAllMask, True);
|
|
||||||
if (which & XkbControlsMask)
|
|
||||||
XkbcFreeControls(xkb, XkbAllControlsMask, True);
|
|
||||||
if (freeAll)
|
|
||||||
free(xkb);
|
free(xkb);
|
||||||
}
|
}
|
||||||
|
|
238
src/galloc.c
238
src/galloc.c
|
@ -31,87 +31,37 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include "XKBcommonint.h"
|
#include "XKBcommonint.h"
|
||||||
#include <X11/extensions/XKB.h>
|
#include <X11/extensions/XKB.h>
|
||||||
|
|
||||||
static void
|
typedef void (*ContentsClearFunc)(void *priv);
|
||||||
_XkbFreeGeomLeafElems(Bool freeAll, int first, int count,
|
|
||||||
unsigned short *num_inout, unsigned short *sz_inout,
|
|
||||||
char **elems, unsigned int elem_sz)
|
|
||||||
{
|
|
||||||
if (freeAll || !(*elems)) {
|
|
||||||
*num_inout = *sz_inout = 0;
|
|
||||||
free(*elems);
|
|
||||||
*elems = NULL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((first >= (*num_inout)) || (first < 0) || (count < 1))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (first + count >= (*num_inout))
|
|
||||||
/* truncating the array is easy */
|
|
||||||
(*num_inout) = first;
|
|
||||||
else {
|
|
||||||
char *ptr = *elems;
|
|
||||||
int extra = ((*num_inout) - first + count) * elem_sz;
|
|
||||||
|
|
||||||
if (extra > 0)
|
|
||||||
memmove(&ptr[first * elem_sz], &ptr[(first + count) * elem_sz],
|
|
||||||
extra);
|
|
||||||
|
|
||||||
(*num_inout) -= count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef void (*ContentsClearFunc)(char *priv);
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_XkbFreeGeomNonLeafElems(Bool freeAll, int first, int count,
|
_XkbFreeGeomNonLeafElems(unsigned short *num_inout, unsigned short *sz_inout,
|
||||||
unsigned short *num_inout, unsigned short *sz_inout,
|
void *elems, size_t elem_sz,
|
||||||
char **elems, unsigned int elem_sz,
|
|
||||||
ContentsClearFunc freeFunc)
|
ContentsClearFunc freeFunc)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *ptr;
|
char *start, *ptr;
|
||||||
|
|
||||||
if (freeAll) {
|
if (!elems)
|
||||||
first = 0;
|
|
||||||
count = *num_inout;
|
|
||||||
}
|
|
||||||
else if ((first >= (*num_inout)) || (first < 0) || (count < 1))
|
|
||||||
return;
|
|
||||||
else if (first + count > (*num_inout))
|
|
||||||
count = (*num_inout) - first;
|
|
||||||
|
|
||||||
if (!(*elems))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (freeFunc) {
|
start = *(char **)elems;
|
||||||
ptr = *elems;
|
if (!start)
|
||||||
ptr += first * elem_sz;
|
return;
|
||||||
for (i = 0; i < count; i++) {
|
|
||||||
(*freeFunc)(ptr);
|
ptr = start;
|
||||||
|
for (i = 0; i < *num_inout; i++) {
|
||||||
|
freeFunc(ptr);
|
||||||
ptr += elem_sz;
|
ptr += elem_sz;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (freeAll) {
|
|
||||||
*num_inout = *sz_inout = 0;
|
*num_inout = *sz_inout = 0;
|
||||||
free(*elems);
|
free(start);
|
||||||
*elems = NULL;
|
|
||||||
}
|
|
||||||
else if (first + count >= (*num_inout))
|
|
||||||
*num_inout = first;
|
|
||||||
else {
|
|
||||||
i = ((*num_inout) - first + count) * elem_sz;
|
|
||||||
ptr = *elems;
|
|
||||||
memmove(&ptr[first * elem_sz], &ptr[(first + count) * elem_sz], i);
|
|
||||||
(*num_inout) -= count;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_XkbClearProperty(char *prop_in)
|
_XkbClearProperty(void *prop_in)
|
||||||
{
|
{
|
||||||
struct xkb_property * prop = (struct xkb_property *)prop_in;
|
struct xkb_property * prop = prop_in;
|
||||||
|
|
||||||
free(prop->name);
|
free(prop->name);
|
||||||
prop->name = NULL;
|
prop->name = NULL;
|
||||||
|
@ -120,118 +70,80 @@ _XkbClearProperty(char *prop_in)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
XkbcFreeGeomProperties(struct xkb_geometry * geom, int first, int count, Bool freeAll)
|
XkbcFreeGeomProperties(struct xkb_geometry * geom)
|
||||||
{
|
{
|
||||||
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
_XkbFreeGeomNonLeafElems(&geom->num_properties, &geom->sz_properties,
|
||||||
&geom->num_properties, &geom->sz_properties,
|
&geom->properties, sizeof(struct xkb_property),
|
||||||
(char **)&geom->properties,
|
|
||||||
sizeof(struct xkb_property),
|
|
||||||
_XkbClearProperty);
|
_XkbClearProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
XkbcFreeGeomKeyAliases(struct xkb_geometry * geom, int first, int count, Bool freeAll)
|
_XkbClearColor(void *color_in)
|
||||||
{
|
{
|
||||||
_XkbFreeGeomLeafElems(freeAll, first, count,
|
struct xkb_color * color = color_in;
|
||||||
&geom->num_key_aliases, &geom->sz_key_aliases,
|
|
||||||
(char **)&geom->key_aliases,
|
|
||||||
sizeof(struct xkb_key_alias));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_XkbClearColor(char *color_in)
|
|
||||||
{
|
|
||||||
struct xkb_color * color = (struct xkb_color *)color_in;
|
|
||||||
|
|
||||||
free(color->spec);
|
free(color->spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
XkbcFreeGeomColors(struct xkb_geometry * geom, int first, int count, Bool freeAll)
|
XkbcFreeGeomColors(struct xkb_geometry * geom)
|
||||||
{
|
{
|
||||||
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
_XkbFreeGeomNonLeafElems(&geom->num_colors, &geom->sz_colors,
|
||||||
&geom->num_colors, &geom->sz_colors,
|
&geom->colors, sizeof(struct xkb_color),
|
||||||
(char **)&geom->colors, sizeof(struct xkb_color),
|
|
||||||
_XkbClearColor);
|
_XkbClearColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
XkbcFreeGeomPoints(struct xkb_outline * outline, int first, int count, Bool freeAll)
|
_XkbClearOutline(void *outline_in)
|
||||||
{
|
{
|
||||||
_XkbFreeGeomLeafElems(freeAll, first, count,
|
struct xkb_outline * outline = outline_in;
|
||||||
&outline->num_points, &outline->sz_points,
|
|
||||||
(char **)&outline->points, sizeof(struct xkb_point));
|
free(outline->points);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_XkbClearOutline(char *outline_in)
|
XkbcFreeGeomOutlines(struct xkb_shape * shape)
|
||||||
{
|
{
|
||||||
struct xkb_outline * outline = (struct xkb_outline *)outline_in;
|
_XkbFreeGeomNonLeafElems(&shape->num_outlines, &shape->sz_outlines,
|
||||||
|
&shape->outlines, sizeof(struct xkb_outline),
|
||||||
if (outline->points)
|
|
||||||
XkbcFreeGeomPoints(outline, 0, outline->num_points, True);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
XkbcFreeGeomOutlines(struct xkb_shape * shape, int first, int count, Bool freeAll)
|
|
||||||
{
|
|
||||||
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
|
||||||
&shape->num_outlines, &shape->sz_outlines,
|
|
||||||
(char **)&shape->outlines, sizeof(struct xkb_outline),
|
|
||||||
_XkbClearOutline);
|
_XkbClearOutline);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_XkbClearShape(char *shape_in)
|
_XkbClearShape(void *shape_in)
|
||||||
{
|
{
|
||||||
struct xkb_shape * shape = (struct xkb_shape *)shape_in;
|
struct xkb_shape * shape = shape_in;
|
||||||
|
|
||||||
if (shape->outlines)
|
XkbcFreeGeomOutlines(shape);
|
||||||
XkbcFreeGeomOutlines(shape, 0, shape->num_outlines, True);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
XkbcFreeGeomShapes(struct xkb_geometry * geom, int first, int count, Bool freeAll)
|
XkbcFreeGeomShapes(struct xkb_geometry * geom)
|
||||||
{
|
{
|
||||||
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
_XkbFreeGeomNonLeafElems(&geom->num_shapes, &geom->sz_shapes,
|
||||||
&geom->num_shapes, &geom->sz_shapes,
|
&geom->shapes, sizeof(struct xkb_shape),
|
||||||
(char **)&geom->shapes, sizeof(struct xkb_shape),
|
|
||||||
_XkbClearShape);
|
_XkbClearShape);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
XkbcFreeGeomKeys(struct xkb_row * row, int first, int count, Bool freeAll)
|
_XkbClearRow(void *row_in)
|
||||||
{
|
{
|
||||||
_XkbFreeGeomLeafElems(freeAll, first, count,
|
struct xkb_row * row = row_in;
|
||||||
&row->num_keys, &row->sz_keys,
|
|
||||||
(char **)&row->keys, sizeof(struct xkb_key));
|
free(row->keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_XkbClearRow(char *row_in)
|
XkbcFreeGeomRows(struct xkb_section * section)
|
||||||
{
|
{
|
||||||
struct xkb_row * row = (struct xkb_row *)row_in;
|
_XkbFreeGeomNonLeafElems(§ion->num_rows, §ion->sz_rows,
|
||||||
|
§ion->rows, sizeof(struct xkb_row),
|
||||||
if (row->keys)
|
|
||||||
XkbcFreeGeomKeys(row, 0, row->num_keys, True);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
XkbcFreeGeomRows(struct xkb_section * section, int first, int count, Bool freeAll)
|
|
||||||
{
|
|
||||||
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
|
||||||
§ion->num_rows, §ion->sz_rows,
|
|
||||||
(char **)§ion->rows, sizeof(struct xkb_row),
|
|
||||||
_XkbClearRow);
|
_XkbClearRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_XkbClearDoodad(char *doodad_in)
|
_XkbClearDoodad(union xkb_doodad *doodad)
|
||||||
{
|
{
|
||||||
union xkb_doodad * doodad = (union xkb_doodad *)doodad_in;
|
|
||||||
|
|
||||||
switch (doodad->any.type) {
|
switch (doodad->any.type) {
|
||||||
case XkbTextDoodad:
|
case XkbTextDoodad:
|
||||||
free(doodad->text.text);
|
free(doodad->text.text);
|
||||||
|
@ -248,73 +160,53 @@ _XkbClearDoodad(char *doodad_in)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
XkbcFreeGeomDoodads(union xkb_doodad * doodads, int nDoodads, Bool freeAll)
|
XkbcFreeGeomDoodads(union xkb_doodad * doodads, int nDoodads)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
union xkb_doodad * doodad;
|
union xkb_doodad * doodad;
|
||||||
|
|
||||||
for (i = 0, doodad = doodads; i < nDoodads && doodad; i++, doodad++)
|
for (i = 0, doodad = doodads; i < nDoodads && doodad; i++, doodad++)
|
||||||
_XkbClearDoodad((char *)doodad);
|
_XkbClearDoodad(doodad);
|
||||||
if (freeAll)
|
|
||||||
free(doodads);
|
free(doodads);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_XkbClearSection(char *section_in)
|
_XkbClearSection(void *section_in)
|
||||||
{
|
{
|
||||||
struct xkb_section * section = (struct xkb_section *)section_in;
|
struct xkb_section * section = section_in;
|
||||||
|
|
||||||
if (section->rows)
|
XkbcFreeGeomRows(section);
|
||||||
XkbcFreeGeomRows(section, 0, section->num_rows, True);
|
XkbcFreeGeomDoodads(section->doodads, section->num_doodads);
|
||||||
XkbcFreeGeomDoodads(section->doodads, section->num_doodads, True);
|
|
||||||
section->doodads = NULL;
|
section->doodads = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
XkbcFreeGeomSections(struct xkb_geometry * geom, int first, int count, Bool freeAll)
|
XkbcFreeGeomSections(struct xkb_geometry * geom)
|
||||||
{
|
{
|
||||||
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
_XkbFreeGeomNonLeafElems(&geom->num_sections, &geom->sz_sections,
|
||||||
&geom->num_sections, &geom->sz_sections,
|
&geom->sections, sizeof(struct xkb_section),
|
||||||
(char **)&geom->sections, sizeof(struct xkb_section),
|
|
||||||
_XkbClearSection);
|
_XkbClearSection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
XkbcFreeGeometry(struct xkb_geometry * geom, unsigned which, Bool freeMap)
|
XkbcFreeGeometry(struct xkb_desc * xkb)
|
||||||
{
|
{
|
||||||
if (!geom)
|
struct xkb_geometry *geom;
|
||||||
|
|
||||||
|
if (!xkb || !xkb->geom)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (freeMap)
|
geom = xkb->geom;
|
||||||
which = XkbGeomAllMask;
|
|
||||||
|
|
||||||
if ((which & XkbGeomPropertiesMask) && geom->properties)
|
XkbcFreeGeomProperties(geom);
|
||||||
XkbcFreeGeomProperties(geom, 0, geom->num_properties, True);
|
XkbcFreeGeomColors(geom);
|
||||||
|
XkbcFreeGeomShapes(geom);
|
||||||
if ((which & XkbGeomColorsMask) && geom->colors)
|
XkbcFreeGeomSections(geom);
|
||||||
XkbcFreeGeomColors(geom, 0, geom->num_colors, True);
|
XkbcFreeGeomDoodads(geom->doodads, geom->num_doodads);
|
||||||
|
free(geom->key_aliases);
|
||||||
if ((which & XkbGeomShapesMask) && geom->shapes)
|
|
||||||
XkbcFreeGeomShapes(geom, 0, geom->num_shapes, True);
|
|
||||||
|
|
||||||
if ((which & XkbGeomSectionsMask) && geom->sections)
|
|
||||||
XkbcFreeGeomSections(geom, 0, geom->num_sections, True);
|
|
||||||
|
|
||||||
if ((which & XkbGeomDoodadsMask) && geom->doodads) {
|
|
||||||
XkbcFreeGeomDoodads(geom->doodads, geom->num_doodads, True);
|
|
||||||
geom->doodads = NULL;
|
|
||||||
geom->num_doodads = geom->sz_doodads = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((which & XkbGeomKeyAliasesMask) && geom->key_aliases)
|
|
||||||
XkbcFreeGeomKeyAliases(geom, 0, geom->num_key_aliases, True);
|
|
||||||
|
|
||||||
if (freeMap) {
|
|
||||||
free(geom->label_font);
|
free(geom->label_font);
|
||||||
geom->label_font = NULL;
|
|
||||||
free(geom);
|
free(geom);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_XkbGeomAlloc(char **old, unsigned short *num, unsigned short *total,
|
_XkbGeomAlloc(char **old, unsigned short *num, unsigned short *total,
|
||||||
|
@ -447,7 +339,7 @@ XkbcAllocGeometry(struct xkb_desc * xkb, struct xkb_geometry_sizes * sizes)
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
bail:
|
bail:
|
||||||
XkbcFreeGeometry(geom, XkbGeomAllMask, True);
|
XkbcFreeGeometry(xkb);
|
||||||
xkb->geom = NULL;
|
xkb->geom = NULL;
|
||||||
return rtrn;
|
return rtrn;
|
||||||
}
|
}
|
||||||
|
|
54
src/malloc.c
54
src/malloc.c
|
@ -380,91 +380,45 @@ XkbcResizeKeyActions(struct xkb_desc * xkb, xkb_keycode_t key, int needed)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
XkbcFreeClientMap(struct xkb_desc * xkb, unsigned what, Bool freeMap)
|
XkbcFreeClientMap(struct xkb_desc * xkb)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
struct xkb_client_map * map;
|
struct xkb_client_map * map;
|
||||||
|
struct xkb_key_type * type;
|
||||||
|
|
||||||
if (!xkb || !xkb->map)
|
if (!xkb || !xkb->map)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (freeMap)
|
|
||||||
what = XkbAllClientInfoMask;
|
|
||||||
map = xkb->map;
|
map = xkb->map;
|
||||||
|
|
||||||
if (what & XkbKeyTypesMask) {
|
|
||||||
int i;
|
|
||||||
struct xkb_key_type * type;
|
|
||||||
|
|
||||||
for (i = 0, type = map->types; i < map->num_types && type; i++, type++) {
|
for (i = 0, type = map->types; i < map->num_types && type; i++, type++) {
|
||||||
free(type->map);
|
free(type->map);
|
||||||
type->map = NULL;
|
|
||||||
free(type->preserve);
|
free(type->preserve);
|
||||||
type->preserve = NULL;
|
|
||||||
type->map_count = 0;
|
|
||||||
free(type->level_names);
|
free(type->level_names);
|
||||||
type->level_names = NULL;
|
|
||||||
}
|
}
|
||||||
free(map->types);
|
free(map->types);
|
||||||
map->num_types = map->size_types = 0;
|
|
||||||
map->types = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (what & XkbKeySymsMask) {
|
|
||||||
free(map->key_sym_map);
|
free(map->key_sym_map);
|
||||||
map->key_sym_map = NULL;
|
|
||||||
free(map->syms);
|
free(map->syms);
|
||||||
map->size_syms = map->num_syms = 0;
|
|
||||||
map->syms = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (what & XkbModifierMapMask) {
|
|
||||||
free(map->modmap);
|
free(map->modmap);
|
||||||
map->modmap = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (freeMap) {
|
|
||||||
free(xkb->map);
|
free(xkb->map);
|
||||||
xkb->map = NULL;
|
xkb->map = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XkbcFreeServerMap(struct xkb_desc * xkb, unsigned what, Bool freeMap)
|
XkbcFreeServerMap(struct xkb_desc * xkb)
|
||||||
{
|
{
|
||||||
struct xkb_server_map * map;
|
struct xkb_server_map * map;
|
||||||
|
|
||||||
if (!xkb || !xkb->server)
|
if (!xkb || !xkb->server)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (freeMap)
|
|
||||||
what = XkbAllServerInfoMask;
|
|
||||||
map = xkb->server;
|
map = xkb->server;
|
||||||
|
|
||||||
if (what & XkbExplicitComponentsMask) {
|
|
||||||
free(map->explicit);
|
free(map->explicit);
|
||||||
map->explicit = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (what & XkbKeyActionsMask) {
|
|
||||||
free(map->key_acts);
|
free(map->key_acts);
|
||||||
map->key_acts = NULL;
|
|
||||||
free(map->acts);
|
free(map->acts);
|
||||||
map->num_acts = map->size_acts = 0;
|
|
||||||
map->acts = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (what & XkbKeyBehaviorsMask) {
|
|
||||||
free(map->behaviors);
|
free(map->behaviors);
|
||||||
map->behaviors = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (what & XkbVirtualModMapMask) {
|
|
||||||
free(map->vmodmap);
|
free(map->vmodmap);
|
||||||
map->vmodmap = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (freeMap) {
|
|
||||||
free(xkb->server);
|
free(xkb->server);
|
||||||
xkb->server = NULL;
|
xkb->server = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -979,7 +979,7 @@ XkbRF_ClearVarDescriptions(XkbRF_DescribeVarsPtr var)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
XkbcRF_Free(XkbRF_RulesPtr rules,Bool freeRules)
|
XkbcRF_Free(XkbRF_RulesPtr rules)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
XkbRF_RulePtr rule;
|
XkbRF_RulePtr rule;
|
||||||
|
@ -996,8 +996,6 @@ XkbcRF_Free(XkbRF_RulesPtr rules,Bool freeRules)
|
||||||
XkbRF_ClearVarDescriptions(&rules->extra[i]);
|
XkbRF_ClearVarDescriptions(&rules->extra[i]);
|
||||||
}
|
}
|
||||||
free(rules->extra);
|
free(rules->extra);
|
||||||
rules->num_extra= rules->sz_extra= 0;
|
|
||||||
rules->extra= NULL;
|
|
||||||
}
|
}
|
||||||
for (i=0, rule = rules->rules; i < rules->num_rules && rules; i++, rule++) {
|
for (i=0, rule = rules->rules; i < rules->num_rules && rules; i++, rule++) {
|
||||||
free(rule->model);
|
free(rule->model);
|
||||||
|
@ -1010,20 +1008,14 @@ XkbcRF_Free(XkbRF_RulesPtr rules,Bool freeRules)
|
||||||
free(rule->compat);
|
free(rule->compat);
|
||||||
free(rule->geometry);
|
free(rule->geometry);
|
||||||
free(rule->keymap);
|
free(rule->keymap);
|
||||||
memset(rule, 0, sizeof(XkbRF_RuleRec));
|
|
||||||
}
|
}
|
||||||
free(rules->rules);
|
free(rules->rules);
|
||||||
rules->num_rules= rules->sz_rules= 0;
|
|
||||||
rules->rules= NULL;
|
|
||||||
|
|
||||||
for (i=0, group = rules->groups; i < rules->num_groups && group; i++, group++) {
|
for (i=0, group = rules->groups; i < rules->num_groups && group; i++, group++) {
|
||||||
free(group->name);
|
free(group->name);
|
||||||
free(group->words);
|
free(group->words);
|
||||||
}
|
}
|
||||||
free(rules->groups);
|
free(rules->groups);
|
||||||
rules->num_groups= 0;
|
|
||||||
rules->groups= NULL;
|
|
||||||
|
|
||||||
if (freeRules)
|
|
||||||
free(rules);
|
free(rules);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ extern struct xkb_desc *
|
||||||
XkbcAllocKeyboard(void);
|
XkbcAllocKeyboard(void);
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
XkbcFreeKeyboard(struct xkb_desc * xkb, unsigned which, Bool freeAll);
|
XkbcFreeKeyboard(struct xkb_desc * xkb);
|
||||||
|
|
||||||
/***====================================================================***/
|
/***====================================================================***/
|
||||||
|
|
||||||
|
@ -68,9 +68,9 @@ extern union xkb_action *
|
||||||
XkbcResizeKeyActions(struct xkb_desc * xkb, xkb_keycode_t key, int needed);
|
XkbcResizeKeyActions(struct xkb_desc * xkb, xkb_keycode_t key, int needed);
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
XkbcFreeClientMap(struct xkb_desc * xkb, unsigned what, Bool freeMap);
|
XkbcFreeClientMap(struct xkb_desc * xkb);
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
XkbcFreeServerMap(struct xkb_desc * xkb, unsigned what, Bool freeMap);
|
XkbcFreeServerMap(struct xkb_desc * xkb);
|
||||||
|
|
||||||
#endif /* _XKBALLOC_H_ */
|
#endif /* _XKBALLOC_H_ */
|
||||||
|
|
|
@ -83,7 +83,7 @@ XkbComponentsFromRules(const char *rules, const XkbRF_VarDefsPtr defs)
|
||||||
|
|
||||||
if (!cached_name || strcmp(rules, cached_name) != 0) {
|
if (!cached_name || strcmp(rules, cached_name) != 0) {
|
||||||
if (loaded)
|
if (loaded)
|
||||||
XkbcRF_Free(loaded, True);
|
XkbcRF_Free(loaded);
|
||||||
loaded = NULL;
|
loaded = NULL;
|
||||||
free(cached_name);
|
free(cached_name);
|
||||||
cached_name = NULL;
|
cached_name = NULL;
|
||||||
|
@ -240,7 +240,7 @@ xkb_compile_keymap_from_components(const struct xkb_component_names * ktcsg)
|
||||||
|
|
||||||
return xkb;
|
return xkb;
|
||||||
unwind_xkb:
|
unwind_xkb:
|
||||||
XkbcFreeKeyboard(xkb, XkbAllComponentsMask, True);
|
XkbcFreeKeyboard(xkb);
|
||||||
unwind_file:
|
unwind_file:
|
||||||
/* XXX: here's where we would free the XkbFile */
|
/* XXX: here's where we would free the XkbFile */
|
||||||
fail:
|
fail:
|
||||||
|
@ -280,7 +280,7 @@ compile_keymap(XkbFile *file, const char *mapName)
|
||||||
|
|
||||||
return xkb;
|
return xkb;
|
||||||
unwind_xkb:
|
unwind_xkb:
|
||||||
XkbcFreeKeyboard(xkb, XkbAllComponentsMask, True);
|
XkbcFreeKeyboard(xkb);
|
||||||
unwind_file:
|
unwind_file:
|
||||||
/* XXX: here's where we would free the XkbFile */
|
/* XXX: here's where we would free the XkbFile */
|
||||||
|
|
||||||
|
@ -328,5 +328,5 @@ xkb_compile_keymap_from_file(FILE *inputFile, const char *mapName)
|
||||||
void
|
void
|
||||||
xkb_free_keymap(struct xkb_desc *xkb)
|
xkb_free_keymap(struct xkb_desc *xkb)
|
||||||
{
|
{
|
||||||
XkbcFreeKeyboard(xkb, 0, True);
|
XkbcFreeKeyboard(xkb);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ authorization from the authors.
|
||||||
#include "xkbcommon/xkbcommon.h"
|
#include "xkbcommon/xkbcommon.h"
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
XkbcFreeGeometry(struct xkb_geometry * geom, unsigned which, Bool freeMap);
|
XkbcFreeGeometry(struct xkb_desc * xkb);
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
XkbcAllocGeomKeyAliases(struct xkb_geometry * geom, int nKeyAliases);
|
XkbcAllocGeomKeyAliases(struct xkb_geometry * geom, int nKeyAliases);
|
||||||
|
|
|
@ -156,6 +156,6 @@ extern Bool
|
||||||
XkbcRF_LoadRules(FILE *file, XkbRF_RulesPtr rules);
|
XkbcRF_LoadRules(FILE *file, XkbRF_RulesPtr rules);
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
XkbcRF_Free(XkbRF_RulesPtr rules, Bool freeRules);
|
XkbcRF_Free(XkbRF_RulesPtr rules);
|
||||||
|
|
||||||
#endif /* _XKBRULES_H_ */
|
#endif /* _XKBRULES_H_ */
|
||||||
|
|
Loading…
Reference in New Issue