dinput: Fix usage of HeapReAlloc.

This commit is contained in:
Vitaliy Margolen 2008-12-28 13:40:47 -07:00 committed by Alexandre Julliard
parent 43b7f268e4
commit a610cfb64c

View File

@ -228,6 +228,7 @@ static void find_joydevs(void)
int fd; int fd;
int no_ff_check = 0; int no_ff_check = 0;
int j; int j;
struct JoyDev *new_joydevs;
snprintf(buf, sizeof(buf), EVDEVPREFIX"%d", i); snprintf(buf, sizeof(buf), EVDEVPREFIX"%d", i);
@ -319,12 +320,18 @@ static void find_joydevs(void)
} }
} }
if (have_joydevs==0) { if (!have_joydevs)
joydevs = HeapAlloc(GetProcessHeap(), 0, sizeof(struct JoyDev)); new_joydevs = HeapAlloc(GetProcessHeap(), 0, sizeof(struct JoyDev));
} else { else
HeapReAlloc(GetProcessHeap(), 0, joydevs, (1+have_joydevs) * sizeof(struct JoyDev)); new_joydevs = HeapReAlloc(GetProcessHeap(), 0, joydevs, (1 + have_joydevs) * sizeof(struct JoyDev));
}
memcpy(joydevs+have_joydevs, &joydev, sizeof(struct JoyDev)); if (!new_joydevs)
{
close(fd);
continue;
}
joydevs = new_joydevs;
memcpy(joydevs + have_joydevs, &joydev, sizeof(joydev));
have_joydevs++; have_joydevs++;
} }