forked from old/legacy-imlib2
Cleanups: while->for loops (context list)
This commit is contained in:
parent
3c645829b4
commit
4f3da0de03
|
@ -26,73 +26,68 @@ __imlib_GetMaxContexts(void)
|
||||||
void
|
void
|
||||||
__imlib_FlushContexts(void)
|
__imlib_FlushContexts(void)
|
||||||
{
|
{
|
||||||
Context *ct, *pct, *ctt;
|
Context *ct, *ct_prev, *ct_next;
|
||||||
|
|
||||||
ct = context;
|
for (ct = context, ct_prev = NULL; ct; ct = ct_next)
|
||||||
pct = NULL;
|
|
||||||
while (ct)
|
|
||||||
{
|
{
|
||||||
ctt = ct;
|
ct_next = ct->next;
|
||||||
ct = ct->next;
|
|
||||||
/* it hasn't been referenced in the last max_context_count references */
|
/* it hasn't been referenced in the last max_context_count references */
|
||||||
/* thus old and getrid of it */
|
/* thus old and getrid of it */
|
||||||
if (ctt->last_use < (context_counter - max_context_count))
|
if (ct->last_use < (context_counter - max_context_count))
|
||||||
{
|
{
|
||||||
if (pct)
|
if (ct_prev)
|
||||||
pct->next = ctt->next;
|
ct_prev->next = ct->next;
|
||||||
else
|
else
|
||||||
context = ctt->next;
|
context = ct->next;
|
||||||
|
if (ct->palette)
|
||||||
if (ctt->palette)
|
|
||||||
{
|
{
|
||||||
int i, num[] = { 256, 128, 64, 32, 16, 8, 1 };
|
int i, num[] = { 256, 128, 64, 32, 16, 8, 1 };
|
||||||
unsigned long pixels[256];
|
unsigned long pixels[256];
|
||||||
|
|
||||||
for (i = 0; i < num[ctt->palette_type]; i++)
|
for (i = 0; i < num[ct->palette_type]; i++)
|
||||||
pixels[i] = (unsigned long)ctt->palette[i];
|
pixels[i] = (unsigned long)ct->palette[i];
|
||||||
XFreeColors(ctt->display, ctt->colormap, pixels,
|
XFreeColors(ct->display, ct->colormap, pixels,
|
||||||
num[ctt->palette_type], 0);
|
num[ct->palette_type], 0);
|
||||||
|
|
||||||
free(ctt->palette);
|
free(ct->palette);
|
||||||
free(ctt->r_dither);
|
free(ct->r_dither);
|
||||||
free(ctt->g_dither);
|
free(ct->g_dither);
|
||||||
free(ctt->b_dither);
|
free(ct->b_dither);
|
||||||
}
|
}
|
||||||
else if (ctt->r_dither)
|
else if (ct->r_dither)
|
||||||
{
|
{
|
||||||
free(ctt->r_dither);
|
free(ct->r_dither);
|
||||||
free(ctt->g_dither);
|
free(ct->g_dither);
|
||||||
free(ctt->b_dither);
|
free(ct->b_dither);
|
||||||
}
|
}
|
||||||
free(ctt);
|
free(ct);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pct = ctt;
|
{
|
||||||
|
ct_prev = ct;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Context *
|
Context *
|
||||||
__imlib_FindContext(Display * d, Visual * v, Colormap c, int depth)
|
__imlib_FindContext(Display * d, Visual * v, Colormap c, int depth)
|
||||||
{
|
{
|
||||||
Context *ct, *pct;
|
Context *ct, *ct_prev;
|
||||||
|
|
||||||
pct = NULL;
|
for (ct = context, ct_prev = NULL; ct; ct_prev = ct, ct = ct->next)
|
||||||
ct = context;
|
|
||||||
while (ct)
|
|
||||||
{
|
{
|
||||||
if ((ct->display == d) && (ct->visual == v) &&
|
if ((ct->display == d) && (ct->visual == v) &&
|
||||||
(ct->colormap == c) && (ct->depth == depth))
|
(ct->colormap == c) && (ct->depth == depth))
|
||||||
{
|
{
|
||||||
if (pct)
|
if (ct_prev)
|
||||||
{
|
{
|
||||||
pct->next = ct->next;
|
ct_prev->next = ct->next;
|
||||||
ct->next = context;
|
ct->next = context;
|
||||||
context = ct;
|
context = ct;
|
||||||
}
|
}
|
||||||
return ct;
|
return ct;
|
||||||
}
|
}
|
||||||
pct = ct;
|
|
||||||
ct = ct->next;
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue