Initialize interface structures so they can be extended in the future

We guarantee that we will only add to the end of these interfaces, and any new fields will be optional.
This commit is contained in:
Sam Lantinga 2024-09-05 16:28:48 -07:00
parent 434193d153
commit 702ed83f72
13 changed files with 130 additions and 22 deletions

View file

@ -142,6 +142,11 @@ SDL_JoystickID SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *des
SDL_InvalidParamError("desc");
return 0;
}
if (desc->version < sizeof(*desc)) {
// Update this to handle older versions of this interface
SDL_SetError("Invalid desc, should be initialized with SDL_INIT_INTERFACE()");
return 0;
}
hwdata = (joystick_hwdata *)SDL_calloc(1, sizeof(joystick_hwdata));
if (!hwdata) {