alloc/galloc: Coding style cleanup
Mostly tab-to-space conversion plus a few style nits. Dropped the register keywords as I'm pretty sure modern compilers can be trusted to do the right thing.master
parent
1ff77ecd36
commit
46faf56ded
909
src/alloc.c
909
src/alloc.c
File diff suppressed because it is too large
Load Diff
642
src/galloc.c
642
src/galloc.c
|
@ -33,507 +33,489 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <X11/extensions/XKB.h>
|
#include <X11/extensions/XKB.h>
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_XkbFreeGeomLeafElems( Bool freeAll,
|
_XkbFreeGeomLeafElems(Bool freeAll, int first, int count,
|
||||||
int first,
|
unsigned short *num_inout, unsigned short *sz_inout,
|
||||||
int count,
|
char **elems, unsigned int elem_sz)
|
||||||
unsigned short * num_inout,
|
|
||||||
unsigned short * sz_inout,
|
|
||||||
char ** elems,
|
|
||||||
unsigned int elem_sz)
|
|
||||||
{
|
{
|
||||||
if ((freeAll)||(*elems==NULL)) {
|
if (freeAll || !(*elems)) {
|
||||||
*num_inout= *sz_inout= 0;
|
*num_inout = *sz_inout = 0;
|
||||||
if (*elems!=NULL) {
|
if (*elems) {
|
||||||
_XkbFree(*elems);
|
_XkbFree(*elems);
|
||||||
*elems= NULL;
|
*elems = NULL;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((first>=(*num_inout))||(first<0)||(count<1))
|
if ((first >= (*num_inout)) || (first < 0) || (count < 1))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (first+count>=(*num_inout)) {
|
if (first + count >= (*num_inout))
|
||||||
/* truncating the array is easy */
|
/* truncating the array is easy */
|
||||||
(*num_inout)= first;
|
(*num_inout) = first;
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
char * ptr;
|
char *ptr = *elems;
|
||||||
int extra;
|
int extra = ((*num_inout) - first + count) * elem_sz;
|
||||||
ptr= *elems;
|
|
||||||
extra= ((*num_inout)-(first+count))*elem_sz;
|
if (extra > 0)
|
||||||
if (extra>0)
|
memmove(&ptr[first * elem_sz], &ptr[(first + count) * elem_sz],
|
||||||
memmove(&ptr[first*elem_sz],&ptr[(first+count)*elem_sz],extra);
|
extra);
|
||||||
(*num_inout)-= count;
|
|
||||||
|
(*num_inout) -= count;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef void (*ContentsClearFunc)(
|
typedef void (*ContentsClearFunc)(char *priv);
|
||||||
char * /* priv */
|
|
||||||
);
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_XkbFreeGeomNonLeafElems( Bool freeAll,
|
_XkbFreeGeomNonLeafElems(Bool freeAll, int first, int count,
|
||||||
int first,
|
unsigned short *num_inout, unsigned short *sz_inout,
|
||||||
int count,
|
char **elems, unsigned int elem_sz,
|
||||||
unsigned short * num_inout,
|
ContentsClearFunc freeFunc)
|
||||||
unsigned short * sz_inout,
|
|
||||||
char ** elems,
|
|
||||||
unsigned int elem_sz,
|
|
||||||
ContentsClearFunc freeFunc)
|
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
register char *ptr;
|
char *ptr;
|
||||||
|
|
||||||
if (freeAll) {
|
if (freeAll) {
|
||||||
first= 0;
|
first = 0;
|
||||||
count= (*num_inout);
|
count = *num_inout;
|
||||||
}
|
}
|
||||||
else if ((first>=(*num_inout))||(first<0)||(count<1))
|
else if ((first >= (*num_inout)) || (first < 0) || (count < 1))
|
||||||
return;
|
return;
|
||||||
else if (first+count>(*num_inout))
|
else if (first + count > (*num_inout))
|
||||||
count= (*num_inout)-first;
|
count = (*num_inout) - first;
|
||||||
if (*elems==NULL)
|
|
||||||
return;
|
if (!(*elems))
|
||||||
|
return;
|
||||||
|
|
||||||
if (freeFunc) {
|
if (freeFunc) {
|
||||||
ptr= *elems;
|
ptr = *elems;
|
||||||
ptr+= first*elem_sz;
|
ptr += first * elem_sz;
|
||||||
for (i=0;i<count;i++) {
|
for (i = 0; i < count; i++) {
|
||||||
(*freeFunc)(ptr);
|
(*freeFunc)(ptr);
|
||||||
ptr+= elem_sz;
|
ptr += elem_sz;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (freeAll) {
|
if (freeAll) {
|
||||||
(*num_inout)= (*sz_inout)= 0;
|
*num_inout = *sz_inout = 0;
|
||||||
if (*elems) {
|
if (*elems) {
|
||||||
_XkbFree(*elems);
|
_XkbFree(*elems);
|
||||||
*elems= NULL;
|
*elems = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (first+count>=(*num_inout))
|
else if (first + count >= (*num_inout))
|
||||||
*num_inout= first;
|
*num_inout = first;
|
||||||
else {
|
else {
|
||||||
i= ((*num_inout)-(first+count))*elem_sz;
|
i = ((*num_inout) - first + count) * elem_sz;
|
||||||
ptr= *elems;
|
ptr = *elems;
|
||||||
memmove(&ptr[first*elem_sz],&ptr[(first+count)*elem_sz],i);
|
memmove(&ptr[first * elem_sz], &ptr[(first + count) * elem_sz], i);
|
||||||
(*num_inout)-= count;
|
(*num_inout) -= count;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_XkbClearProperty(char *prop_in)
|
_XkbClearProperty(char *prop_in)
|
||||||
{
|
{
|
||||||
XkbPropertyPtr prop= (XkbPropertyPtr)prop_in;
|
XkbPropertyPtr prop = (XkbPropertyPtr)prop_in;
|
||||||
|
|
||||||
if (prop->name) {
|
if (prop->name) {
|
||||||
_XkbFree(prop->name);
|
_XkbFree(prop->name);
|
||||||
prop->name= NULL;
|
prop->name = NULL;
|
||||||
}
|
}
|
||||||
if (prop->value) {
|
if (prop->value) {
|
||||||
_XkbFree(prop->value);
|
_XkbFree(prop->value);
|
||||||
prop->value= NULL;
|
prop->value = NULL;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
XkbcFreeGeomProperties( XkbGeometryPtr geom,
|
XkbcFreeGeomProperties(XkbGeometryPtr geom, int first, int count, Bool freeAll)
|
||||||
int first,
|
|
||||||
int count,
|
|
||||||
Bool freeAll)
|
|
||||||
{
|
{
|
||||||
_XkbFreeGeomNonLeafElems(freeAll,first,count,
|
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
||||||
&geom->num_properties,&geom->sz_properties,
|
&geom->num_properties, &geom->sz_properties,
|
||||||
(char **)&geom->properties,
|
(char **)&geom->properties,
|
||||||
sizeof(XkbPropertyRec),_XkbClearProperty);
|
sizeof(XkbPropertyRec),
|
||||||
return;
|
_XkbClearProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
XkbcFreeGeomKeyAliases( XkbGeometryPtr geom,
|
XkbcFreeGeomKeyAliases(XkbGeometryPtr geom, int first, int count, Bool freeAll)
|
||||||
int first,
|
|
||||||
int count,
|
|
||||||
Bool freeAll)
|
|
||||||
{
|
{
|
||||||
_XkbFreeGeomLeafElems(freeAll,first,count,
|
_XkbFreeGeomLeafElems(freeAll, first, count,
|
||||||
&geom->num_key_aliases,&geom->sz_key_aliases,
|
&geom->num_key_aliases, &geom->sz_key_aliases,
|
||||||
(char **)&geom->key_aliases,
|
(char **)&geom->key_aliases,
|
||||||
sizeof(XkbKeyAliasRec));
|
sizeof(XkbKeyAliasRec));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_XkbClearColor(char *color_in)
|
_XkbClearColor(char *color_in)
|
||||||
{
|
{
|
||||||
XkbColorPtr color= (XkbColorPtr)color_in;
|
XkbColorPtr color = (XkbColorPtr)color_in;
|
||||||
|
|
||||||
if (color->spec)
|
if (color->spec)
|
||||||
_XkbFree(color->spec);
|
_XkbFree(color->spec);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
XkbcFreeGeomColors(XkbGeometryPtr geom,int first,int count,Bool freeAll)
|
XkbcFreeGeomColors(XkbGeometryPtr geom, int first, int count, Bool freeAll)
|
||||||
{
|
{
|
||||||
_XkbFreeGeomNonLeafElems(freeAll,first,count,
|
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
||||||
&geom->num_colors,&geom->sz_colors,
|
&geom->num_colors, &geom->sz_colors,
|
||||||
(char **)&geom->colors,
|
(char **)&geom->colors, sizeof(XkbColorRec),
|
||||||
sizeof(XkbColorRec),_XkbClearColor);
|
_XkbClearColor);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
XkbcFreeGeomPoints(XkbOutlinePtr outline,int first,int count,Bool freeAll)
|
XkbcFreeGeomPoints(XkbOutlinePtr outline, int first, int count, Bool freeAll)
|
||||||
{
|
{
|
||||||
_XkbFreeGeomLeafElems(freeAll,first,count,
|
_XkbFreeGeomLeafElems(freeAll, first, count,
|
||||||
&outline->num_points,&outline->sz_points,
|
&outline->num_points, &outline->sz_points,
|
||||||
(char **)&outline->points,
|
(char **)&outline->points, sizeof(XkbPointRec));
|
||||||
sizeof(XkbPointRec));
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_XkbClearOutline(char *outline_in)
|
_XkbClearOutline(char *outline_in)
|
||||||
{
|
{
|
||||||
XkbOutlinePtr outline= (XkbOutlinePtr)outline_in;
|
XkbOutlinePtr outline = (XkbOutlinePtr)outline_in;
|
||||||
|
|
||||||
if (outline->points!=NULL)
|
if (outline->points)
|
||||||
XkbcFreeGeomPoints(outline,0,outline->num_points,True);
|
XkbcFreeGeomPoints(outline, 0, outline->num_points, True);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
XkbcFreeGeomOutlines(XkbShapePtr shape,int first,int count,Bool freeAll)
|
XkbcFreeGeomOutlines(XkbShapePtr shape, int first, int count, Bool freeAll)
|
||||||
{
|
{
|
||||||
_XkbFreeGeomNonLeafElems(freeAll,first,count,
|
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
||||||
&shape->num_outlines,&shape->sz_outlines,
|
&shape->num_outlines, &shape->sz_outlines,
|
||||||
(char **)&shape->outlines,
|
(char **)&shape->outlines, sizeof(XkbOutlineRec),
|
||||||
sizeof(XkbOutlineRec),_XkbClearOutline);
|
_XkbClearOutline);
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_XkbClearShape(char *shape_in)
|
_XkbClearShape(char *shape_in)
|
||||||
{
|
{
|
||||||
XkbShapePtr shape= (XkbShapePtr)shape_in;
|
XkbShapePtr shape = (XkbShapePtr)shape_in;
|
||||||
|
|
||||||
if (shape->outlines)
|
if (shape->outlines)
|
||||||
XkbcFreeGeomOutlines(shape,0,shape->num_outlines,True);
|
XkbcFreeGeomOutlines(shape, 0, shape->num_outlines, True);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
XkbcFreeGeomShapes(XkbGeometryPtr geom,int first,int count,Bool freeAll)
|
XkbcFreeGeomShapes(XkbGeometryPtr geom, int first, int count, Bool freeAll)
|
||||||
{
|
{
|
||||||
_XkbFreeGeomNonLeafElems(freeAll,first,count,
|
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
||||||
&geom->num_shapes,&geom->sz_shapes,
|
&geom->num_shapes, &geom->sz_shapes,
|
||||||
(char **)&geom->shapes,
|
(char **)&geom->shapes, sizeof(XkbShapeRec),
|
||||||
sizeof(XkbShapeRec),_XkbClearShape);
|
_XkbClearShape);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
XkbcFreeGeomOverlayKeys(XkbOverlayRowPtr row,int first,int count,Bool freeAll)
|
XkbcFreeGeomOverlayKeys(XkbOverlayRowPtr row, int first, int count,
|
||||||
|
Bool freeAll)
|
||||||
{
|
{
|
||||||
_XkbFreeGeomLeafElems(freeAll,first,count,
|
_XkbFreeGeomLeafElems(freeAll, first, count,
|
||||||
&row->num_keys,&row->sz_keys,
|
&row->num_keys, &row->sz_keys,
|
||||||
(char **)&row->keys,
|
(char **)&row->keys, sizeof(XkbOverlayKeyRec));
|
||||||
sizeof(XkbOverlayKeyRec));
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_XkbClearOverlayRow(char *row_in)
|
_XkbClearOverlayRow(char *row_in)
|
||||||
{
|
{
|
||||||
XkbOverlayRowPtr row= (XkbOverlayRowPtr)row_in;
|
XkbOverlayRowPtr row = (XkbOverlayRowPtr)row_in;
|
||||||
|
|
||||||
if (row->keys!=NULL)
|
if (row->keys)
|
||||||
XkbcFreeGeomOverlayKeys(row,0,row->num_keys,True);
|
XkbcFreeGeomOverlayKeys(row, 0, row->num_keys, True);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
XkbcFreeGeomOverlayRows(XkbOverlayPtr overlay,int first,int count,Bool freeAll)
|
XkbcFreeGeomOverlayRows(XkbOverlayPtr overlay, int first, int count,
|
||||||
|
Bool freeAll)
|
||||||
{
|
{
|
||||||
_XkbFreeGeomNonLeafElems(freeAll,first,count,
|
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
||||||
&overlay->num_rows,&overlay->sz_rows,
|
&overlay->num_rows, &overlay->sz_rows,
|
||||||
(char **)&overlay->rows,
|
(char **)&overlay->rows,
|
||||||
sizeof(XkbOverlayRowRec),_XkbClearOverlayRow);
|
sizeof(XkbOverlayRowRec),
|
||||||
return;
|
_XkbClearOverlayRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_XkbClearOverlay(char *overlay_in)
|
_XkbClearOverlay(char *overlay_in)
|
||||||
{
|
{
|
||||||
XkbOverlayPtr overlay= (XkbOverlayPtr)overlay_in;
|
XkbOverlayPtr overlay = (XkbOverlayPtr)overlay_in;
|
||||||
|
|
||||||
if (overlay->rows!=NULL)
|
if (overlay->rows)
|
||||||
XkbcFreeGeomOverlayRows(overlay,0,overlay->num_rows,True);
|
XkbcFreeGeomOverlayRows(overlay, 0, overlay->num_rows, True);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
XkbcFreeGeomOverlays(XkbSectionPtr section,int first,int count,Bool freeAll)
|
XkbcFreeGeomOverlays(XkbSectionPtr section, int first, int count, Bool freeAll)
|
||||||
{
|
{
|
||||||
_XkbFreeGeomNonLeafElems(freeAll,first,count,
|
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
||||||
§ion->num_overlays,§ion->sz_overlays,
|
§ion->num_overlays, §ion->sz_overlays,
|
||||||
(char **)§ion->overlays,
|
(char **)§ion->overlays,
|
||||||
sizeof(XkbOverlayRec),_XkbClearOverlay);
|
sizeof(XkbOverlayRec),
|
||||||
return;
|
_XkbClearOverlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XkbcFreeGeomKeys(XkbRowPtr row,int first,int count,Bool freeAll)
|
XkbcFreeGeomKeys(XkbRowPtr row, int first, int count, Bool freeAll)
|
||||||
{
|
{
|
||||||
_XkbFreeGeomLeafElems(freeAll,first,count,
|
_XkbFreeGeomLeafElems(freeAll, first, count,
|
||||||
&row->num_keys,&row->sz_keys,
|
&row->num_keys, &row->sz_keys,
|
||||||
(char **)&row->keys,
|
(char **)&row->keys, sizeof(XkbKeyRec));
|
||||||
sizeof(XkbKeyRec));
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_XkbClearRow(char *row_in)
|
_XkbClearRow(char *row_in)
|
||||||
{
|
{
|
||||||
XkbRowPtr row= (XkbRowPtr)row_in;
|
XkbRowPtr row = (XkbRowPtr)row_in;
|
||||||
|
|
||||||
if (row->keys!=NULL)
|
if (row->keys)
|
||||||
XkbcFreeGeomKeys(row,0,row->num_keys,True);
|
XkbcFreeGeomKeys(row, 0, row->num_keys, True);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
XkbcFreeGeomRows(XkbSectionPtr section,int first,int count,Bool freeAll)
|
XkbcFreeGeomRows(XkbSectionPtr section, int first, int count, Bool freeAll)
|
||||||
{
|
{
|
||||||
_XkbFreeGeomNonLeafElems(freeAll,first,count,
|
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
||||||
§ion->num_rows,§ion->sz_rows,
|
§ion->num_rows, §ion->sz_rows,
|
||||||
(char **)§ion->rows,
|
(char **)§ion->rows, sizeof(XkbRowRec),
|
||||||
sizeof(XkbRowRec),_XkbClearRow);
|
_XkbClearRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_XkbClearSection(char *section_in)
|
_XkbClearSection(char *section_in)
|
||||||
{
|
{
|
||||||
XkbSectionPtr section= (XkbSectionPtr)section_in;
|
XkbSectionPtr section = (XkbSectionPtr)section_in;
|
||||||
|
|
||||||
if (section->rows!=NULL)
|
if (section->rows)
|
||||||
XkbcFreeGeomRows(section,0,section->num_rows,True);
|
XkbcFreeGeomRows(section, 0, section->num_rows, True);
|
||||||
if (section->doodads!=NULL) {
|
if (section->doodads) {
|
||||||
XkbcFreeGeomDoodads(section->doodads,section->num_doodads,True);
|
XkbcFreeGeomDoodads(section->doodads, section->num_doodads, True);
|
||||||
section->doodads= NULL;
|
section->doodads = NULL;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
XkbcFreeGeomSections(XkbGeometryPtr geom,int first,int count,Bool freeAll)
|
XkbcFreeGeomSections(XkbGeometryPtr geom, int first, int count, Bool freeAll)
|
||||||
{
|
{
|
||||||
_XkbFreeGeomNonLeafElems(freeAll,first,count,
|
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
||||||
&geom->num_sections,&geom->sz_sections,
|
&geom->num_sections, &geom->sz_sections,
|
||||||
(char **)&geom->sections,
|
(char **)&geom->sections, sizeof(XkbSectionRec),
|
||||||
sizeof(XkbSectionRec),_XkbClearSection);
|
_XkbClearSection);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_XkbClearDoodad(char *doodad_in)
|
_XkbClearDoodad(char *doodad_in)
|
||||||
{
|
{
|
||||||
XkbDoodadPtr doodad= (XkbDoodadPtr)doodad_in;
|
XkbDoodadPtr doodad = (XkbDoodadPtr)doodad_in;
|
||||||
|
|
||||||
switch (doodad->any.type) {
|
switch (doodad->any.type) {
|
||||||
case XkbTextDoodad:
|
case XkbTextDoodad:
|
||||||
{
|
if (doodad->text.text) {
|
||||||
if (doodad->text.text!=NULL) {
|
_XkbFree(doodad->text.text);
|
||||||
_XkbFree(doodad->text.text);
|
doodad->text.text = NULL;
|
||||||
doodad->text.text= NULL;
|
}
|
||||||
}
|
if (doodad->text.font) {
|
||||||
if (doodad->text.font!=NULL) {
|
_XkbFree(doodad->text.font);
|
||||||
_XkbFree(doodad->text.font);
|
doodad->text.font = NULL;
|
||||||
doodad->text.font= NULL;
|
}
|
||||||
}
|
break;
|
||||||
}
|
|
||||||
break;
|
case XkbLogoDoodad:
|
||||||
case XkbLogoDoodad:
|
if (doodad->logo.logo_name) {
|
||||||
{
|
_XkbFree(doodad->logo.logo_name);
|
||||||
if (doodad->logo.logo_name!=NULL) {
|
doodad->logo.logo_name = NULL;
|
||||||
_XkbFree(doodad->logo.logo_name);
|
}
|
||||||
doodad->logo.logo_name= NULL;
|
break;
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
XkbcFreeGeomDoodads(XkbDoodadPtr doodads,int nDoodads,Bool freeAll)
|
XkbcFreeGeomDoodads(XkbDoodadPtr doodads, int nDoodads, Bool freeAll)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
register XkbDoodadPtr doodad;
|
XkbDoodadPtr doodad;
|
||||||
|
|
||||||
if (doodads) {
|
if (doodads) {
|
||||||
for (i=0,doodad= doodads;i<nDoodads;i++,doodad++) {
|
for (i = 0, doodad = doodads; i < nDoodads; i++, doodad++)
|
||||||
_XkbClearDoodad((char *)doodad);
|
_XkbClearDoodad((char *)doodad);
|
||||||
}
|
if (freeAll)
|
||||||
if (freeAll)
|
_XkbFree(doodads);
|
||||||
_XkbFree(doodads);
|
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
XkbcFreeGeometry(XkbGeometryPtr geom,unsigned which,Bool freeMap)
|
XkbcFreeGeometry(XkbGeometryPtr geom, unsigned which, Bool freeMap)
|
||||||
{
|
{
|
||||||
if (geom==NULL)
|
if (!geom)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (freeMap)
|
if (freeMap)
|
||||||
which= XkbGeomAllMask;
|
which = XkbGeomAllMask;
|
||||||
if ((which&XkbGeomPropertiesMask)&&(geom->properties!=NULL))
|
|
||||||
XkbcFreeGeomProperties(geom,0,geom->num_properties,True);
|
if ((which & XkbGeomPropertiesMask) && geom->properties)
|
||||||
if ((which&XkbGeomColorsMask)&&(geom->colors!=NULL))
|
XkbcFreeGeomProperties(geom, 0, geom->num_properties, True);
|
||||||
XkbcFreeGeomColors(geom,0,geom->num_colors,True);
|
|
||||||
if ((which&XkbGeomShapesMask)&&(geom->shapes!=NULL))
|
if ((which & XkbGeomColorsMask) && geom->colors)
|
||||||
XkbcFreeGeomShapes(geom,0,geom->num_shapes,True);
|
XkbcFreeGeomColors(geom, 0, geom->num_colors, True);
|
||||||
if ((which&XkbGeomSectionsMask)&&(geom->sections!=NULL))
|
|
||||||
XkbcFreeGeomSections(geom,0,geom->num_sections,True);
|
if ((which & XkbGeomShapesMask) && geom->shapes)
|
||||||
if ((which&XkbGeomDoodadsMask)&&(geom->doodads!= NULL)) {
|
XkbcFreeGeomShapes(geom, 0, geom->num_shapes, True);
|
||||||
XkbcFreeGeomDoodads(geom->doodads,geom->num_doodads,True);
|
|
||||||
geom->doodads= NULL;
|
if ((which & XkbGeomSectionsMask) && geom->sections)
|
||||||
geom->num_doodads= geom->sz_doodads= 0;
|
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!=NULL))
|
|
||||||
XkbcFreeGeomKeyAliases(geom,0,geom->num_key_aliases,True);
|
if ((which & XkbGeomKeyAliasesMask) && geom->key_aliases)
|
||||||
|
XkbcFreeGeomKeyAliases(geom, 0, geom->num_key_aliases, True);
|
||||||
|
|
||||||
if (freeMap) {
|
if (freeMap) {
|
||||||
if (geom->label_font!=NULL) {
|
if (geom->label_font) {
|
||||||
_XkbFree(geom->label_font);
|
_XkbFree(geom->label_font);
|
||||||
geom->label_font= NULL;
|
geom->label_font = NULL;
|
||||||
}
|
}
|
||||||
_XkbFree(geom);
|
_XkbFree(geom);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_XkbGeomAlloc( char ** old,
|
_XkbGeomAlloc(char **old, unsigned short *num, unsigned short *total,
|
||||||
unsigned short * num,
|
int num_new, size_t sz_elem)
|
||||||
unsigned short * total,
|
|
||||||
int num_new,
|
|
||||||
size_t sz_elem)
|
|
||||||
{
|
{
|
||||||
if (num_new<1)
|
if (num_new < 1)
|
||||||
return Success;
|
return Success;
|
||||||
if ((*old)==NULL)
|
|
||||||
*num= *total= 0;
|
|
||||||
|
|
||||||
if ((*num)+num_new<=(*total))
|
if (!(*old))
|
||||||
return Success;
|
*num = *total = 0;
|
||||||
|
|
||||||
*total= (*num)+num_new;
|
if ((*num) + num_new <= (*total))
|
||||||
if ((*old)!=NULL)
|
return Success;
|
||||||
(*old)= (char *)_XkbRealloc((*old),(*total)*sz_elem);
|
|
||||||
else (*old)= (char *)_XkbCalloc((*total),sz_elem);
|
*total = (*num) + num_new;
|
||||||
if ((*old)==NULL) {
|
|
||||||
*total= *num= 0;
|
if (*old)
|
||||||
return BadAlloc;
|
*old = (char *)_XkbRealloc(*old, (*total) * sz_elem);
|
||||||
|
else
|
||||||
|
*old = (char *)_XkbCalloc(*total, sz_elem);
|
||||||
|
if (!(*old)) {
|
||||||
|
*total = *num = 0;
|
||||||
|
return BadAlloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*num>0) {
|
if (*num > 0) {
|
||||||
char *tmp= (char *)(*old);
|
char *tmp = *old;
|
||||||
bzero(&tmp[sz_elem*(*num)],(num_new*sz_elem));
|
bzero(&tmp[sz_elem * (*num)], num_new * sz_elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define _XkbAllocProps(g,n) _XkbGeomAlloc((char **)&(g)->properties,\
|
#define _XkbAllocProps(g, n) _XkbGeomAlloc((char **)&(g)->properties, \
|
||||||
&(g)->num_properties,&(g)->sz_properties,\
|
&(g)->num_properties, \
|
||||||
(n),sizeof(XkbPropertyRec))
|
&(g)->sz_properties, \
|
||||||
#define _XkbAllocColors(g,n) _XkbGeomAlloc((char **)&(g)->colors,\
|
(n), sizeof(XkbPropertyRec))
|
||||||
&(g)->num_colors,&(g)->sz_colors,\
|
#define _XkbAllocColors(g, n) _XkbGeomAlloc((char **)&(g)->colors, \
|
||||||
(n),sizeof(XkbColorRec))
|
&(g)->num_colors, \
|
||||||
#define _XkbAllocShapes(g,n) _XkbGeomAlloc((char **)&(g)->shapes,\
|
&(g)->sz_colors, \
|
||||||
&(g)->num_shapes,&(g)->sz_shapes,\
|
(n), sizeof(XkbColorRec))
|
||||||
(n),sizeof(XkbShapeRec))
|
#define _XkbAllocShapes(g, n) _XkbGeomAlloc((char **)&(g)->shapes, \
|
||||||
#define _XkbAllocSections(g,n) _XkbGeomAlloc((char **)&(g)->sections,\
|
&(g)->num_shapes, \
|
||||||
&(g)->num_sections,&(g)->sz_sections,\
|
&(g)->sz_shapes, \
|
||||||
(n),sizeof(XkbSectionRec))
|
(n), sizeof(XkbShapeRec))
|
||||||
#define _XkbAllocDoodads(g,n) _XkbGeomAlloc((char **)&(g)->doodads,\
|
#define _XkbAllocSections(g, n) _XkbGeomAlloc((char **)&(g)->sections, \
|
||||||
&(g)->num_doodads,&(g)->sz_doodads,\
|
&(g)->num_sections, \
|
||||||
(n),sizeof(XkbDoodadRec))
|
&(g)->sz_sections, \
|
||||||
#define _XkbAllocKeyAliases(g,n) _XkbGeomAlloc((char **)&(g)->key_aliases,\
|
(n), sizeof(XkbSectionRec))
|
||||||
&(g)->num_key_aliases,&(g)->sz_key_aliases,\
|
#define _XkbAllocDoodads(g, n) _XkbGeomAlloc((char **)&(g)->doodads, \
|
||||||
(n),sizeof(XkbKeyAliasRec))
|
&(g)->num_doodads, \
|
||||||
|
&(g)->sz_doodads, \
|
||||||
|
(n), sizeof(XkbDoodadRec))
|
||||||
|
#define _XkbAllocKeyAliases(g, n) _XkbGeomAlloc((char **)&(g)->key_aliases, \
|
||||||
|
&(g)->num_key_aliases, \
|
||||||
|
&(g)->sz_key_aliases, \
|
||||||
|
(n), sizeof(XkbKeyAliasRec))
|
||||||
|
|
||||||
#define _XkbAllocOutlines(s,n) _XkbGeomAlloc((char **)&(s)->outlines,\
|
#define _XkbAllocOutlines(s, n) _XkbGeomAlloc((char **)&(s)->outlines, \
|
||||||
&(s)->num_outlines,&(s)->sz_outlines,\
|
&(s)->num_outlines, \
|
||||||
(n),sizeof(XkbOutlineRec))
|
&(s)->sz_outlines, \
|
||||||
#define _XkbAllocRows(s,n) _XkbGeomAlloc((char **)&(s)->rows,\
|
(n), sizeof(XkbOutlineRec))
|
||||||
&(s)->num_rows,&(s)->sz_rows,\
|
#define _XkbAllocRows(s, n) _XkbGeomAlloc((char **)&(s)->rows, \
|
||||||
(n),sizeof(XkbRowRec))
|
&(s)->num_rows, \
|
||||||
#define _XkbAllocPoints(o,n) _XkbGeomAlloc((char **)&(o)->points,\
|
&(s)->sz_rows, \
|
||||||
&(o)->num_points,&(o)->sz_points,\
|
(n), sizeof(XkbRowRec))
|
||||||
(n),sizeof(XkbPointRec))
|
#define _XkbAllocPoints(o, n) _XkbGeomAlloc((char **)&(o)->points, \
|
||||||
#define _XkbAllocKeys(r,n) _XkbGeomAlloc((char **)&(r)->keys,\
|
&(o)->num_points, \
|
||||||
&(r)->num_keys,&(r)->sz_keys,\
|
&(o)->sz_points, \
|
||||||
(n),sizeof(XkbKeyRec))
|
(n), sizeof(XkbPointRec))
|
||||||
#define _XkbAllocOverlays(s,n) _XkbGeomAlloc((char **)&(s)->overlays,\
|
#define _XkbAllocKeys(r, n) _XkbGeomAlloc((char **)&(r)->keys, \
|
||||||
&(s)->num_overlays,&(s)->sz_overlays,\
|
&(r)->num_keys, \
|
||||||
(n),sizeof(XkbOverlayRec))
|
&(r)->sz_keys, \
|
||||||
#define _XkbAllocOverlayRows(o,n) _XkbGeomAlloc((char **)&(o)->rows,\
|
(n), sizeof(XkbKeyRec))
|
||||||
&(o)->num_rows,&(o)->sz_rows,\
|
#define _XkbAllocOverlays(s, n) _XkbGeomAlloc((char **)&(s)->overlays, \
|
||||||
(n),sizeof(XkbOverlayRowRec))
|
&(s)->num_overlays, \
|
||||||
#define _XkbAllocOverlayKeys(r,n) _XkbGeomAlloc((char **)&(r)->keys,\
|
&(s)->sz_overlays, \
|
||||||
&(r)->num_keys,&(r)->sz_keys,\
|
(n), sizeof(XkbOverlayRec))
|
||||||
(n),sizeof(XkbOverlayKeyRec))
|
#define _XkbAllocOverlayRows(o, n) _XkbGeomAlloc((char **)&(o)->rows, \
|
||||||
|
&(o)->num_rows, \
|
||||||
|
&(o)->sz_rows, \
|
||||||
|
(n), sizeof(XkbOverlayRowRec))
|
||||||
|
#define _XkbAllocOverlayKeys(r, n) _XkbGeomAlloc((char **)&(r)->keys, \
|
||||||
|
&(r)->num_keys, \
|
||||||
|
&(r)->sz_keys, \
|
||||||
|
(n), sizeof(XkbOverlayKeyRec))
|
||||||
|
|
||||||
int
|
int
|
||||||
XkbcAllocGeometry(XkbcDescPtr xkb,XkbGeometrySizesPtr sizes)
|
XkbcAllocGeometry(XkbcDescPtr xkb, XkbGeometrySizesPtr sizes)
|
||||||
{
|
{
|
||||||
XkbGeometryPtr geom;
|
XkbGeometryPtr geom;
|
||||||
int rtrn;
|
int rtrn;
|
||||||
|
|
||||||
if (xkb->geom==NULL) {
|
if (!xkb->geom) {
|
||||||
xkb->geom= _XkbTypedCalloc(1,XkbGeometryRec);
|
xkb->geom = _XkbTypedCalloc(1, XkbGeometryRec);
|
||||||
if (!xkb->geom)
|
if (!xkb->geom)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
}
|
|
||||||
geom= xkb->geom;
|
|
||||||
if ((sizes->which&XkbGeomPropertiesMask)&&
|
|
||||||
((rtrn=_XkbAllocProps(geom,sizes->num_properties))!=Success)) {
|
|
||||||
goto BAIL;
|
|
||||||
}
|
|
||||||
if ((sizes->which&XkbGeomColorsMask)&&
|
|
||||||
((rtrn=_XkbAllocColors(geom,sizes->num_colors))!=Success)) {
|
|
||||||
goto BAIL;
|
|
||||||
}
|
|
||||||
if ((sizes->which&XkbGeomShapesMask)&&
|
|
||||||
((rtrn=_XkbAllocShapes(geom,sizes->num_shapes))!=Success)) {
|
|
||||||
goto BAIL;
|
|
||||||
}
|
|
||||||
if ((sizes->which&XkbGeomSectionsMask)&&
|
|
||||||
((rtrn=_XkbAllocSections(geom,sizes->num_sections))!=Success)) {
|
|
||||||
goto BAIL;
|
|
||||||
}
|
|
||||||
if ((sizes->which&XkbGeomDoodadsMask)&&
|
|
||||||
((rtrn=_XkbAllocDoodads(geom,sizes->num_doodads))!=Success)) {
|
|
||||||
goto BAIL;
|
|
||||||
}
|
|
||||||
if ((sizes->which&XkbGeomKeyAliasesMask)&&
|
|
||||||
((rtrn=_XkbAllocKeyAliases(geom,sizes->num_key_aliases))!=Success)) {
|
|
||||||
goto BAIL;
|
|
||||||
}
|
}
|
||||||
|
geom = xkb->geom;
|
||||||
|
|
||||||
|
if ((sizes->which & XkbGeomPropertiesMask) &&
|
||||||
|
((rtrn = _XkbAllocProps(geom, sizes->num_properties)) != Success))
|
||||||
|
goto bail;
|
||||||
|
|
||||||
|
if ((sizes->which & XkbGeomColorsMask) &&
|
||||||
|
((rtrn = _XkbAllocColors(geom, sizes->num_colors)) != Success))
|
||||||
|
goto bail;
|
||||||
|
|
||||||
|
if ((sizes->which & XkbGeomShapesMask) &&
|
||||||
|
((rtrn = _XkbAllocShapes(geom, sizes->num_shapes)) != Success))
|
||||||
|
goto bail;
|
||||||
|
|
||||||
|
if ((sizes->which & XkbGeomSectionsMask) &&
|
||||||
|
((rtrn = _XkbAllocSections(geom, sizes->num_sections)) != Success))
|
||||||
|
goto bail;
|
||||||
|
|
||||||
|
if ((sizes->which & XkbGeomDoodadsMask) &&
|
||||||
|
((rtrn = _XkbAllocDoodads(geom, sizes->num_doodads)) != Success))
|
||||||
|
goto bail;
|
||||||
|
|
||||||
|
if ((sizes->which & XkbGeomKeyAliasesMask) &&
|
||||||
|
((rtrn = _XkbAllocKeyAliases(geom, sizes->num_key_aliases)) != Success))
|
||||||
|
goto bail;
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
BAIL:
|
bail:
|
||||||
XkbcFreeGeometry(geom,XkbGeomAllMask,True);
|
XkbcFreeGeometry(geom, XkbGeomAllMask, True);
|
||||||
xkb->geom= NULL;
|
xkb->geom = NULL;
|
||||||
return rtrn;
|
return rtrn;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue