Don't copy structs to stack in cmpmodes(), use const pointers instead.
(and return 0 immediately if the pointers are the same.)
This commit is contained in:
parent
0df5b7f912
commit
3137c0fc68
1 changed files with 14 additions and 17 deletions
|
@ -360,23 +360,20 @@ SDL_DestroyWindowTexture(_THIS, SDL_Window * window)
|
||||||
static int
|
static int
|
||||||
cmpmodes(const void *A, const void *B)
|
cmpmodes(const void *A, const void *B)
|
||||||
{
|
{
|
||||||
SDL_DisplayMode a = *(const SDL_DisplayMode *) A;
|
const SDL_DisplayMode *a = (const SDL_DisplayMode *) A;
|
||||||
SDL_DisplayMode b = *(const SDL_DisplayMode *) B;
|
const SDL_DisplayMode *b = (const SDL_DisplayMode *) B;
|
||||||
|
if (a == b) {
|
||||||
if (a.w != b.w) {
|
return 0;
|
||||||
return b.w - a.w;
|
} else if (a->w != b->w) {
|
||||||
}
|
return b->w - a->w;
|
||||||
if (a.h != b.h) {
|
} else if (a->h != b->h) {
|
||||||
return b.h - a.h;
|
return b->h - a->h;
|
||||||
}
|
} else if (SDL_BITSPERPIXEL(a->format) != SDL_BITSPERPIXEL(b->format)) {
|
||||||
if (SDL_BITSPERPIXEL(a.format) != SDL_BITSPERPIXEL(b.format)) {
|
return SDL_BITSPERPIXEL(b->format) - SDL_BITSPERPIXEL(a->format);
|
||||||
return SDL_BITSPERPIXEL(b.format) - SDL_BITSPERPIXEL(a.format);
|
} else if (SDL_PIXELLAYOUT(a->format) != SDL_PIXELLAYOUT(b->format)) {
|
||||||
}
|
return SDL_PIXELLAYOUT(b->format) - SDL_PIXELLAYOUT(a->format);
|
||||||
if (SDL_PIXELLAYOUT(a.format) != SDL_PIXELLAYOUT(b.format)) {
|
} else if (a->refresh_rate != b->refresh_rate) {
|
||||||
return SDL_PIXELLAYOUT(b.format) - SDL_PIXELLAYOUT(a.format);
|
return b->refresh_rate - a->refresh_rate;
|
||||||
}
|
|
||||||
if (a.refresh_rate != b.refresh_rate) {
|
|
||||||
return b.refresh_rate - a.refresh_rate;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue