#define False 0
#endif
-#ifdef MALLOC_0_RETURNS_NULL
-# define Xmalloc(size) malloc(((size) == 0 ? 1 : (size)))
-# define Xrealloc(ptr, size) realloc((ptr), ((size) == 0 ? 1 : (size)))
-# define Xcalloc(nelem, elsize) calloc(((nelem) == 0 ? 1 : (nelem)), (elsize))
-#else
-# define Xmalloc(size) malloc((size))
-# define Xrealloc(ptr, size) realloc((ptr), (size))
-# define Xcalloc(nelem, elsize) calloc((nelem), (elsize))
-#endif
-
-#define _XkbAlloc(s) Xmalloc((s))
-#define _XkbCalloc(n,s) Xcalloc((n),(s))
-#define _XkbRealloc(o,s) Xrealloc((o),(s))
-#define _XkbTypedAlloc(t) ((t *)Xmalloc(sizeof(t)))
-#define _XkbTypedCalloc(n,t) ((t *)Xcalloc((n),sizeof(t)))
+#define _XkbTypedAlloc(t) ((t *)malloc(sizeof(t)))
+#define _XkbTypedCalloc(n,t) ((t *)calloc((n),sizeof(t)))
#define _XkbTypedRealloc(o,n,t) \
- ((o)?(t *)Xrealloc((o),(n)*sizeof(t)):_XkbTypedCalloc(n,t))
+ ((o)?(t *)realloc((o),(n)*sizeof(t)):_XkbTypedCalloc(n,t))
#define _XkbClearElems(a,f,l,t) bzero(&(a)[f],((l)-(f)+1)*sizeof(t))
-#define _XkbFree(p) free((p))
#define _XkbDupString(s) ((s) ? strdup(s) : NULL)
#define _XkbStrCaseCmp strcasecmp
compat->sym_interpret = _XkbTypedRealloc(compat->sym_interpret,
nSI, XkbcSymInterpretRec);
if (!compat->sym_interpret) {
- _XkbFree(prev_interpret);
+ free(prev_interpret);
compat->size_si = compat->num_si = 0;
return BadAlloc;
}
if (nSI > 0) {
compat->sym_interpret = _XkbTypedCalloc(nSI, XkbcSymInterpretRec);
if (!compat->sym_interpret) {
- _XkbFree(compat);
+ free(compat);
return BadAlloc;
}
}
if (which & XkbSymInterpMask) {
if (compat->sym_interpret && (compat->size_si > 0))
- _XkbFree(compat->sym_interpret);
+ free(compat->sym_interpret);
compat->size_si = compat->num_si = 0;
compat->sym_interpret = NULL;
}
if (freeMap) {
- _XkbFree(compat);
+ free(compat);
xkb->compat = NULL;
}
}
_XkbClearElems(names->key_aliases, names->num_key_aliases,
nTotalAliases - 1, XkbKeyAliasRec);
else
- _XkbFree(prev_aliases);
+ free(prev_aliases);
}
if (!names->key_aliases) {
_XkbClearElems(names->radio_groups, names->num_rg,
nTotalRG - 1, uint32_t);
else
- _XkbFree(prev_radio_groups);
+ free(prev_radio_groups);
}
if (!names->radio_groups)
for (i = 0; i < map->num_types; i++, type++) {
if (type->level_names) {
- _XkbFree(type->level_names);
+ free(type->level_names);
type->level_names = NULL;
}
}
}
if ((which & XkbKeyNamesMask) && names->keys) {
- _XkbFree(names->keys);
+ free(names->keys);
names->keys = NULL;
names->num_keys = 0;
}
if ((which & XkbKeyAliasesMask) && names->key_aliases) {
- _XkbFree(names->key_aliases);
+ free(names->key_aliases);
names->key_aliases = NULL;
names->num_key_aliases = 0;
}
if ((which & XkbRGNamesMask) && names->radio_groups) {
- _XkbFree(names->radio_groups);
+ free(names->radio_groups);
names->radio_groups = NULL;
names->num_rg = 0;
}
if (freeMap) {
- _XkbFree(names);
+ free(names);
xkb->names = NULL;
}
}
XkbcFreeControls(XkbcDescPtr xkb, unsigned which, Bool freeMap)
{
if (freeMap && xkb && xkb->ctrls) {
- _XkbFree(xkb->ctrls);
+ free(xkb->ctrls);
xkb->ctrls = NULL;
}
}
XkbcFreeIndicatorMaps(XkbcDescPtr xkb)
{
if (xkb && xkb->indicators) {
- _XkbFree(xkb->indicators);
+ free(xkb->indicators);
xkb->indicators = NULL;
}
}
if (which & XkbControlsMask)
XkbcFreeControls(xkb, XkbAllControlsMask, True);
if (freeAll)
- _XkbFree(xkb);
+ free(xkb);
}
return;
tableLength = InitialTableSize;
- nodeTable = (NodePtr *)_XkbAlloc(InitialTableSize * sizeof(NodePtr));
+ nodeTable = (NodePtr *)malloc(InitialTableSize * sizeof(NodePtr));
nodeTable[None] = NULL;
}
if (makeit) {
NodePtr nd;
- nd = (NodePtr)_XkbAlloc(sizeof(NodeRec));
+ nd = (NodePtr)malloc(sizeof(NodeRec));
if (!nd)
return BAD_RESOURCE;
- nd->string = (char *)_XkbAlloc(len + 1);
+ nd->string = (char *)malloc(len + 1);
if (!nd->string) {
- _XkbFree(nd);
+ free(nd);
return BAD_RESOURCE;
}
strncpy(nd->string, string, (int)len);
if ((lastAtom + 1) >= tableLength) {
NodePtr *table;
- table = (NodePtr *)_XkbRealloc(nodeTable,
+ table = (NodePtr *)realloc(nodeTable,
tableLength * 2 * sizeof(NodePtr));
if (!table) {
if (nd->string != string)
- _XkbFree(nd->string);
- _XkbFree(nd);
+ free(nd->string);
+ free(nd);
return BAD_RESOURCE;
}
tableLength <<= 1;
if (freeAll || !(*elems)) {
*num_inout = *sz_inout = 0;
if (*elems) {
- _XkbFree(*elems);
+ free(*elems);
*elems = NULL;
}
return;
if (freeAll) {
*num_inout = *sz_inout = 0;
if (*elems) {
- _XkbFree(*elems);
+ free(*elems);
*elems = NULL;
}
}
XkbcPropertyPtr prop = (XkbcPropertyPtr)prop_in;
if (prop->name) {
- _XkbFree(prop->name);
+ free(prop->name);
prop->name = NULL;
}
if (prop->value) {
- _XkbFree(prop->value);
+ free(prop->value);
prop->value = NULL;
}
}
XkbcColorPtr color = (XkbcColorPtr)color_in;
if (color->spec)
- _XkbFree(color->spec);
+ free(color->spec);
}
void
switch (doodad->any.type) {
case XkbTextDoodad:
if (doodad->text.text) {
- _XkbFree(doodad->text.text);
+ free(doodad->text.text);
doodad->text.text = NULL;
}
if (doodad->text.font) {
- _XkbFree(doodad->text.font);
+ free(doodad->text.font);
doodad->text.font = NULL;
}
break;
case XkbLogoDoodad:
if (doodad->logo.logo_name) {
- _XkbFree(doodad->logo.logo_name);
+ free(doodad->logo.logo_name);
doodad->logo.logo_name = NULL;
}
break;
for (i = 0, doodad = doodads; i < nDoodads; i++, doodad++)
_XkbClearDoodad((char *)doodad);
if (freeAll)
- _XkbFree(doodads);
+ free(doodads);
}
}
if (freeMap) {
if (geom->label_font) {
- _XkbFree(geom->label_font);
+ free(geom->label_font);
geom->label_font = NULL;
}
- _XkbFree(geom);
+ free(geom);
}
}
*total = (*num) + num_new;
if (*old)
- *old = (char *)_XkbRealloc(*old, (*total) * sz_elem);
+ *old = (char *)realloc(*old, (*total) * sz_elem);
else
- *old = (char *)_XkbCalloc(*total, sz_elem);
+ *old = (char *)calloc(*total, sz_elem);
if (!(*old)) {
*total = *num = 0;
return BadAlloc;
for (i=0,prop=geom->properties;i<geom->num_properties;i++,prop++) {
if ((prop->name)&&(strcmp(name,prop->name)==0)) {
if (prop->value)
- _XkbFree(prop->value);
- prop->value= (char *)_XkbAlloc(strlen(value)+1);
+ free(prop->value);
+ prop->value= (char *)malloc(strlen(value)+1);
if (prop->value)
strcpy(prop->value,value);
return prop;
return NULL;
}
prop= &geom->properties[geom->num_properties];
- prop->name= (char *)_XkbAlloc(strlen(name)+1);
+ prop->name= (char *)malloc(strlen(name)+1);
if (!name)
return NULL;
strcpy(prop->name,name);
- prop->value= (char *)_XkbAlloc(strlen(value)+1);
+ prop->value= (char *)malloc(strlen(value)+1);
if (!value) {
- _XkbFree(prop->name);
+ free(prop->name);
prop->name= NULL;
return NULL;
}
}
color= &geom->colors[geom->num_colors];
color->pixel= pixel;
- color->spec= (char *)_XkbAlloc(strlen(spec)+1);
+ color->spec= (char *)malloc(strlen(spec)+1);
if (!color->spec)
return NULL;
strcpy(color->spec,spec);
return NULL;
if ((sz_doodads>0)&&(_XkbAllocDoodads(section,sz_doodads)!=Success)) {
if (section->rows) {
- _XkbFree(section->rows);
+ free(section->rows);
section->rows= NULL;
section->sz_rows= section->num_rows= 0;
}
map->types = _XkbTypedRealloc(map->types, nTotalTypes,
XkbcKeyTypeRec);
if (!map->types) {
- _XkbFree(prev_types);
+ free(prev_types);
map->num_types = map->size_types = 0;
return BadAlloc;
}
need = map->num_acts + nNewActions;
map->acts = _XkbTypedRealloc(map->acts, need, union xkb_action);
if (!map->acts) {
- _XkbFree(prev_acts);
+ free(prev_acts);
map->num_acts = map->size_acts = 0;
return BadAlloc;
}
return BadMatch;
if (into->map) {
- _XkbFree(into->map);
+ free(into->map);
into->map = NULL;
}
if (into->preserve) {
- _XkbFree(into->preserve);
+ free(into->preserve);
into->preserve= NULL;
}
if (into->level_names) {
- _XkbFree(into->level_names);
+ free(into->level_names);
into->level_names = NULL;
}
if (map_count == 0) {
if (type->map)
- _XkbFree(type->map);
+ free(type->map);
type->map = NULL;
if (type->preserve)
- _XkbFree(type->preserve);
+ free(type->preserve);
type->preserve = NULL;
type->map_count = 0;
XkbcKTMapEntryRec);
if (!type->map) {
if (prev_map)
- _XkbFree(prev_map);
+ free(prev_map);
return BadAlloc;
}
XkbcModsRec);
if (!type->preserve) {
if (prev_preserve)
- _XkbFree(prev_preserve);
+ free(prev_preserve);
return BadAlloc;
}
}
else if (type->preserve) {
- _XkbFree(type->preserve);
+ free(type->preserve);
type->preserve = NULL;
}
uint32_t);
if (!type->level_names) {
if (prev_level_names)
- _XkbFree(prev_level_names);
+ free(prev_level_names);
return BadAlloc;
}
}
}
type->num_levels = new_num_lvls;
- _XkbFree(xkb->map->syms);
+ free(xkb->map->syms);
xkb->map->syms = newSyms;
xkb->map->num_syms = nSyms;
nSyms += nKeySyms;
}
- _XkbFree(xkb->map->syms);
+ free(xkb->map->syms);
xkb->map->syms = newSyms;
xkb->map->num_syms = nSyms;
maxKC + 1,
XkbSymMapRec);
if (!xkb->map->key_sym_map) {
- _XkbFree(prev_key_sym_map);
+ free(prev_key_sym_map);
return BadAlloc;
}
xkb->map->modmap = _XkbTypedRealloc(xkb->map->modmap,
maxKC + 1, unsigned char);
if (!xkb->map->modmap) {
- _XkbFree(prev_modmap);
+ free(prev_modmap);
return BadAlloc;
}
maxKC + 1,
XkbBehavior);
if (!xkb->server->behaviors) {
- _XkbFree(prev_behaviors);
+ free(prev_behaviors);
return BadAlloc;
}
maxKC + 1,
unsigned short);
if (!xkb->server->key_acts) {
- _XkbFree(prev_key_acts);
+ free(prev_key_acts);
return BadAlloc;
}
maxKC + 1,
uint32_t);
if (!xkb->server->vmodmap) {
- _XkbFree(prev_vmodmap);
+ free(prev_vmodmap);
return BadAlloc;
}
xkb->names->keys = _XkbTypedRealloc(xkb->names->keys, maxKC + 1,
XkbKeyNameRec);
if (!xkb->names->keys) {
- _XkbFree(prev_keys);
+ free(prev_keys);
return BadAlloc;
}
nActs += nKeyActs;
}
- _XkbFree(xkb->server->acts);
+ free(xkb->server->acts);
xkb->server->acts = newActs;
xkb->server->num_acts = nActs;
for (i = 0, type = map->types; i < map->num_types; i++, type++) {
if (type->map) {
- _XkbFree(type->map);
+ free(type->map);
type->map = NULL;
}
if (type->preserve) {
- _XkbFree(type->preserve);
+ free(type->preserve);
type->preserve = NULL;
}
type->map_count = 0;
if (type->level_names) {
- _XkbFree(type->level_names);
+ free(type->level_names);
type->level_names = NULL;
}
}
}
- _XkbFree(map->types);
+ free(map->types);
map->num_types = map->size_types = 0;
map->types = NULL;
}
if (what & XkbKeySymsMask) {
if (map->key_sym_map) {
- _XkbFree(map->key_sym_map);
+ free(map->key_sym_map);
map->key_sym_map = NULL;
}
if (map->syms) {
- _XkbFree(map->syms);
+ free(map->syms);
map->size_syms = map->num_syms = 0;
map->syms = NULL;
}
}
if ((what & XkbModifierMapMask) && map->modmap) {
- _XkbFree(map->modmap);
+ free(map->modmap);
map->modmap = NULL;
}
if (freeMap) {
- _XkbFree(xkb->map);
+ free(xkb->map);
xkb->map = NULL;
}
}
map = xkb->server;
if ((what & XkbExplicitComponentsMask) && map->explicit) {
- _XkbFree(map->explicit);
+ free(map->explicit);
map->explicit = NULL;
}
if (what & XkbKeyActionsMask) {
if (map->key_acts) {
- _XkbFree(map->key_acts);
+ free(map->key_acts);
map->key_acts = NULL;
}
if (map->acts) {
- _XkbFree(map->acts);
+ free(map->acts);
map->num_acts = map->size_acts = 0;
map->acts = NULL;
}
}
if ((what & XkbKeyBehaviorsMask) && map->behaviors) {
- _XkbFree(map->behaviors);
+ free(map->behaviors);
map->behaviors = NULL;
}
if ((what & XkbVirtualModMapMask) && map->vmodmap) {
- _XkbFree(map->vmodmap);
+ free(map->vmodmap);
map->vmodmap = NULL;
}
if (freeMap) {
- _XkbFree(xkb->server);
+ free(xkb->server);
xkb->server = NULL;
}
}
FreeInputLine(InputLine *line)
{
if (line->line!=line->buf)
- _XkbFree(line->line);
+ free(line->line);
line->line_num= 1;
line->num_line= 0;
line->sz_line= DFLT_LINE_SIZE;
{
if (line->num_line>=line->sz_line) {
if (line->line==line->buf) {
- line->line= (char *)_XkbAlloc(line->sz_line*2);
+ line->line= (char *)malloc(line->sz_line*2);
memcpy(line->line,line->buf,line->sz_line);
}
else {
- line->line=(char *)_XkbRealloc((char *)line->line,line->sz_line*2);
+ line->line=(char *)realloc((char *)line->line,line->sz_line*2);
}
line->sz_line*= 2;
}
static void
FreeMultiDefs(XkbRF_MultiDefsPtr defs)
{
- if (defs->options) _XkbFree(defs->options);
- if (defs->layout[1]) _XkbFree(defs->layout[1]);
- if (defs->variant[1]) _XkbFree(defs->variant[1]);
+ if (defs->options) free(defs->options);
+ if (defs->layout[1]) free(defs->layout[1]);
+ if (defs->variant[1]) free(defs->variant[1]);
}
static void
}
str= index(&str[0],'%');
}
- name= (char *)_XkbAlloc(len+1);
+ name= (char *)malloc(len+1);
str= orig;
outstr= name;
while (*str!='\0') {
}
*outstr++= '\0';
if (orig!=name)
- _XkbFree(orig);
+ free(orig);
return name;
}
rules->sz_rules= szRules;
rules->rules= _XkbTypedCalloc(rules->sz_rules,XkbRF_RuleRec);
if (!rules->rules) {
- _XkbFree(rules);
+ free(rules);
return NULL;
}
}
rules->extra= _XkbTypedCalloc(rules->sz_extra,XkbRF_DescribeVarsRec);
if (!rules->extra) {
if (rules->rules)
- _XkbFree(rules->rules);
- _XkbFree(rules);
+ free(rules->rules);
+ free(rules);
return NULL;
}
}
for (i=0;i<var->num_desc;i++) {
if (var->desc[i].name)
- _XkbFree(var->desc[i].name);
+ free(var->desc[i].name);
if (var->desc[i].desc)
- _XkbFree(var->desc[i].desc);
+ free(var->desc[i].desc);
var->desc[i].name= var->desc[i].desc= NULL;
}
if (var->desc)
- _XkbFree(var->desc);
+ free(var->desc);
var->desc= NULL;
return;
}
for (i = 0; i < rules->num_extra; i++) {
XkbRF_ClearVarDescriptions(&rules->extra[i]);
}
- _XkbFree(rules->extra);
+ free(rules->extra);
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) _XkbFree(rule->model);
- if (rule->layout) _XkbFree(rule->layout);
- if (rule->variant) _XkbFree(rule->variant);
- if (rule->option) _XkbFree(rule->option);
- if (rule->keycodes) _XkbFree(rule->keycodes);
- if (rule->symbols) _XkbFree(rule->symbols);
- if (rule->types) _XkbFree(rule->types);
- if (rule->compat) _XkbFree(rule->compat);
- if (rule->geometry) _XkbFree(rule->geometry);
- if (rule->keymap) _XkbFree(rule->keymap);
+ 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));
}
- _XkbFree(rules->rules);
+ 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) _XkbFree(group->name);
- if (group->words) _XkbFree(group->words);
+ if (group->name) free(group->name);
+ if (group->words) free(group->words);
}
- _XkbFree(rules->groups);
+ free(rules->groups);
rules->num_groups= 0;
rules->groups= NULL;
}
if (freeRules)
- _XkbFree(rules);
+ free(rules);
return;
}
tmp = XkbcAtomGetString(vmodNames[ndx]);
if (!tmp) {
- tmp = _XkbAlloc(20 * sizeof(char));
+ tmp = malloc(20 * sizeof(char));
snprintf(tmp, 20, "%d", ndx);
}
rtrn = tbGetBuffer(len);
strncpy(rtrn, tmp, len);
- _XkbFree(tmp);
+ free(tmp);
return rtrn;
}
else
cp->sz *= 2;
- cp->comp = _XkbRealloc(cp->comp,
+ cp->comp = realloc(cp->comp,
cp->sz * sizeof(XkbComponentNameRec));
if (!cp->comp) {
ERROR("Failed reallocating component name list\n");
if (map->name) {
size_t len = strlen(fileName) + strlen(map->name) + 3;
- cp->comp[cp->num].name = _XkbAlloc(len * sizeof(char));
+ cp->comp[cp->num].name = malloc(len * sizeof(char));
if (!cp->comp[cp->num].name) {
ERROR("Could not allocate space for component name\n");
return False;
/* Trim excess component slots */
if (cp.sz > 0 && cp.sz > cp.num) {
- if (_XkbRealloc(cp.comp, cp.num * sizeof(XkbComponentNameRec)))
+ if (realloc(cp.comp, cp.num * sizeof(XkbComponentNameRec)))
cp.sz = cp.num;
else
WARN("Could not reallocate component name list\n");
}
if (!XkbcRF_GetComponents(loaded, defs, names)) {
- _XkbFree(names->keymap);
- _XkbFree(names->keycodes);
- _XkbFree(names->types);
- _XkbFree(names->compat);
- _XkbFree(names->symbols);
- _XkbFree(names->geometry);
- _XkbFree(names);
+ free(names->keymap);
+ free(names->keycodes);
+ free(names->types);
+ free(names->compat);
+ free(names->symbols);
+ free(names->geometry);
+ free(names);
names = NULL;
ERROR("no components returned from XKB rules \"%s\"\n", rulesPath);
}
xkb = XkbcCompileKeymapFromComponents(names);
- _XkbFree(names->keymap);
- _XkbFree(names->keycodes);
- _XkbFree(names->types);
- _XkbFree(names->compat);
- _XkbFree(names->symbols);
- _XkbFree(names->geometry);
- _XkbFree(names);
+ free(names->keymap);
+ free(names->keycodes);
+ free(names->types);
+ free(names->compat);
+ free(names->symbols);
+ free(names->geometry);
+ free(names);
return xkb;
}