mi: miInitVisuals: clean up variable declarations
The code is easier to understand when variables are declared where they're used for the first time, scoped to where they're needed and not reused for separate things. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
4898415c6b
commit
d84bca91ec
46
mi/micmap.c
46
mi/micmap.c
|
@ -432,41 +432,31 @@ miInitVisuals(VisualPtr * visualp, DepthPtr * depthp, int *nvisualp,
|
||||||
unsigned long sizes, int bitsPerRGB, int preferredVis)
|
unsigned long sizes, int bitsPerRGB, int preferredVis)
|
||||||
{
|
{
|
||||||
int i, j = 0, k;
|
int i, j = 0, k;
|
||||||
VisualPtr visual;
|
|
||||||
DepthPtr depth;
|
|
||||||
VisualID *vid;
|
|
||||||
int d, b;
|
|
||||||
int f;
|
int f;
|
||||||
int ndepth, nvisual;
|
|
||||||
int nvtype;
|
|
||||||
int vtype;
|
|
||||||
miVisualsPtr visuals, nextVisuals;
|
miVisualsPtr visuals, nextVisuals;
|
||||||
int *preferredCVCs, *prefp;
|
|
||||||
int first_depth;
|
|
||||||
|
|
||||||
/* none specified, we'll guess from pixmap formats */
|
/* none specified, we'll guess from pixmap formats */
|
||||||
if (!miVisuals) {
|
if (!miVisuals) {
|
||||||
for (f = 0; f < screenInfo.numPixmapFormats; f++) {
|
for (f = 0; f < screenInfo.numPixmapFormats; f++) {
|
||||||
d = screenInfo.formats[f].depth;
|
int d = screenInfo.formats[f].depth;
|
||||||
b = screenInfo.formats[f].bitsPerPixel;
|
int b = screenInfo.formats[f].bitsPerPixel;
|
||||||
if (sizes & (1 << (b - 1)))
|
int vtype = ((sizes & (1 << (b - 1))) ? miGetDefaultVisualMask(d) : 0);
|
||||||
vtype = miGetDefaultVisualMask(d);
|
|
||||||
else
|
|
||||||
vtype = 0;
|
|
||||||
if (!miSetVisualTypes(d, vtype, bitsPerRGB, -1))
|
if (!miSetVisualTypes(d, vtype, bitsPerRGB, -1))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nvisual = 0;
|
|
||||||
ndepth = 0;
|
int nvisual = 0;
|
||||||
|
int ndepth = 0;
|
||||||
for (visuals = miVisuals; visuals; visuals = nextVisuals) {
|
for (visuals = miVisuals; visuals; visuals = nextVisuals) {
|
||||||
nextVisuals = visuals->next;
|
nextVisuals = visuals->next;
|
||||||
ndepth++;
|
ndepth++;
|
||||||
nvisual += visuals->count;
|
nvisual += visuals->count;
|
||||||
}
|
}
|
||||||
depth = xallocarray(ndepth, sizeof(DepthRec));
|
|
||||||
visual = xallocarray(nvisual, sizeof(VisualRec));
|
DepthPtr depth = xallocarray(ndepth, sizeof(DepthRec));
|
||||||
preferredCVCs = xallocarray(ndepth, sizeof(int));
|
VisualPtr visual = xallocarray(nvisual, sizeof(VisualRec));
|
||||||
|
int *preferredCVCs = xallocarray(ndepth, sizeof(int));
|
||||||
if (!depth || !visual || !preferredCVCs) {
|
if (!depth || !visual || !preferredCVCs) {
|
||||||
free(depth);
|
free(depth);
|
||||||
free(visual);
|
free(visual);
|
||||||
|
@ -477,15 +467,17 @@ miInitVisuals(VisualPtr * visualp, DepthPtr * depthp, int *nvisualp,
|
||||||
*visualp = visual;
|
*visualp = visual;
|
||||||
*ndepthp = ndepth;
|
*ndepthp = ndepth;
|
||||||
*nvisualp = nvisual;
|
*nvisualp = nvisual;
|
||||||
prefp = preferredCVCs;
|
|
||||||
|
int *prefp = preferredCVCs;
|
||||||
for (visuals = miVisuals; visuals; visuals = nextVisuals) {
|
for (visuals = miVisuals; visuals; visuals = nextVisuals) {
|
||||||
|
int d = visuals->depth;
|
||||||
|
int vtype = visuals->visuals;
|
||||||
|
int nvtype = visuals->count;
|
||||||
|
|
||||||
nextVisuals = visuals->next;
|
nextVisuals = visuals->next;
|
||||||
d = visuals->depth;
|
VisualID *vid = NULL;
|
||||||
vtype = visuals->visuals;
|
|
||||||
nvtype = visuals->count;
|
|
||||||
*prefp = visuals->preferredCVC;
|
*prefp = visuals->preferredCVC;
|
||||||
prefp++;
|
prefp++;
|
||||||
vid = NULL;
|
|
||||||
if (nvtype) {
|
if (nvtype) {
|
||||||
vid = xallocarray(nvtype, sizeof(VisualID));
|
vid = xallocarray(nvtype, sizeof(VisualID));
|
||||||
if (!vid) {
|
if (!vid) {
|
||||||
|
@ -498,7 +490,6 @@ miInitVisuals(VisualPtr * visualp, DepthPtr * depthp, int *nvisualp,
|
||||||
depth->depth = d;
|
depth->depth = d;
|
||||||
depth->numVids = nvtype;
|
depth->numVids = nvtype;
|
||||||
depth->vids = vid;
|
depth->vids = vid;
|
||||||
depth++;
|
|
||||||
for (i = 0; i < NUM_PRIORITY; i++) {
|
for (i = 0; i < NUM_PRIORITY; i++) {
|
||||||
if (!(vtype & (1 << miVisualPriority[i])))
|
if (!(vtype & (1 << miVisualPriority[i])))
|
||||||
continue;
|
continue;
|
||||||
|
@ -533,6 +524,7 @@ miInitVisuals(VisualPtr * visualp, DepthPtr * depthp, int *nvisualp,
|
||||||
vid++;
|
vid++;
|
||||||
visual++;
|
visual++;
|
||||||
}
|
}
|
||||||
|
depth++;
|
||||||
free(visuals);
|
free(visuals);
|
||||||
}
|
}
|
||||||
miVisuals = NULL;
|
miVisuals = NULL;
|
||||||
|
@ -545,7 +537,7 @@ miInitVisuals(VisualPtr * visualp, DepthPtr * depthp, int *nvisualp,
|
||||||
* structures - if there is, we want to start looking for the
|
* structures - if there is, we want to start looking for the
|
||||||
* default visual/depth from that depth.
|
* default visual/depth from that depth.
|
||||||
*/
|
*/
|
||||||
first_depth = 0;
|
int first_depth = 0;
|
||||||
if (preferredVis < 0 && defaultColorVisualClass < 0) {
|
if (preferredVis < 0 && defaultColorVisualClass < 0) {
|
||||||
for (i = 0; i < ndepth; i++) {
|
for (i = 0; i < ndepth; i++) {
|
||||||
if (preferredCVCs[i] >= 0) {
|
if (preferredCVCs[i] >= 0) {
|
||||||
|
|
Loading…
Reference in New Issue