Skip to content

Commit 89973d6

Browse files
author
龙虾机器人
committed
C89 buildfix: Move variable declarations to block start in xmb_render()
Fixes C89 compliance issue where variables were declared mid-block: - Move static retro_time_t last_scroll_time to function start - Move static unsigned scroll_count to function start - Move retro_time_t current_time to function start - Move bool rapid_scroll to function start This ensures all declarations are at the beginning of the block, as required by the C89 standard. Refs PR libretro#18828
1 parent 856a40c commit 89973d6

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

menu/drivers/xmb.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6847,6 +6847,12 @@ static void xmb_render(void *data,
68476847
unsigned last = (unsigned)end;
68486848
unsigned gfx_thumbnail_upscale_threshold = settings->uints.gfx_thumbnail_upscale_threshold;
68496849
bool network_on_demand_thumbnails = settings->bools.network_on_demand_thumbnails;
6850+
/* LOW-MEMORY FIX: Variables for rapid scroll detection
6851+
* Must be declared at block start for C89 compliance */
6852+
static retro_time_t last_scroll_time = 0;
6853+
static unsigned scroll_count = 0;
6854+
retro_time_t current_time;
6855+
bool rapid_scroll;
68506856

68516857
if (!xmb)
68526858
return;
@@ -7152,20 +7158,18 @@ static void xmb_render(void *data,
71527158
{
71537159
/* LOW-MEMORY FIX: Detect rapid scrolling and defer thumbnail loading
71547160
* This prevents texture exhaustion on devices like Raspberry Pi and Switch */
7155-
static retro_time_t last_scroll_time = 0;
7156-
static unsigned scroll_count = 0;
7157-
retro_time_t current_time = cpu_features_get_time_usec();
7158-
7161+
current_time = cpu_features_get_time_usec();
7162+
71597163
/* Count scrolls within 100ms window */
71607164
if (current_time - last_scroll_time < 100000)
71617165
scroll_count++;
71627166
else
71637167
scroll_count = 1;
7164-
7168+
71657169
last_scroll_time = current_time;
7166-
7170+
71677171
/* If scrolling rapidly (>5 scrolls in 100ms), skip thumbnail loading */
7168-
bool rapid_scroll = (scroll_count > 5);
7172+
rapid_scroll = (scroll_count > 5);
71697173

71707174
if (!rapid_scroll)
71717175
{

0 commit comments

Comments
 (0)