fix realloc usage and increase user data capacity

This commit is contained in:
chayleaf 2023-03-10 03:22:26 +07:00
parent c3e023f9ee
commit 0840549568

View file

@ -76,10 +76,14 @@ BOOL __stdcall wine_bass_user_data_add_ex(DWORD key, DWORD altKey, void *val) {
WINE_BASS_DATA_STORAGE.data = malloc(64 * sizeof(UserDataEntry)); WINE_BASS_DATA_STORAGE.data = malloc(64 * sizeof(UserDataEntry));
WINE_BASS_DATA_STORAGE.capacity = 64; WINE_BASS_DATA_STORAGE.capacity = 64;
} else { } else {
WINE_BASS_DATA_STORAGE.data = realloc(WINE_BASS_DATA_STORAGE.data, 2 * WINE_BASS_DATA_STORAGE.capacity * sizeof(UserDataEntry)); void *new = realloc(WINE_BASS_DATA_STORAGE.data, 2 * WINE_BASS_DATA_STORAGE.capacity * sizeof(UserDataEntry));
if (new) {
WINE_BASS_DATA_STORAGE.data = new;
WINE_BASS_DATA_STORAGE.capacity *= 2;
}
} }
} }
if (!WINE_BASS_DATA_STORAGE.data) { if (!WINE_BASS_DATA_STORAGE.data || WINE_BASS_DATA_STORAGE.count == WINE_BASS_DATA_STORAGE.capacity) {
goto CLEANUP; goto CLEANUP;
} }
UserDataEntry entry = { UserDataEntry entry = {