Simpler pointer arithmetic

This commit is contained in:
Sam Lantinga 2024-07-19 12:51:59 -07:00
parent b80784fced
commit 02dceed760
2 changed files with 2 additions and 2 deletions

View file

@ -747,7 +747,7 @@ const SDL_CameraSpec * const *SDL_GetCameraSupportedFormats(SDL_CameraID instanc
int num_specs = device->num_specs;
const SDL_CameraSpec **retval = (const SDL_CameraSpec **) SDL_malloc(((num_specs + 1) * sizeof(*retval)) + (num_specs * sizeof (**retval)));
if (retval) {
SDL_CameraSpec *specs = (SDL_CameraSpec *)((Uint8 *)retval + ((num_specs + 1) * sizeof(*retval)));
SDL_CameraSpec *specs = (SDL_CameraSpec *)(retval + (num_specs + 1));
SDL_memcpy(specs, device->all_specs, num_specs * sizeof(*specs));
for (i = 0; i < num_specs; ++i) {
retval[i] = specs++;

View file

@ -56,7 +56,7 @@ static const SDL_Locale * const *build_locales_from_csv_string(char *csv, int *c
if (!retval) {
return NULL; /* oh well */
}
loc = (SDL_Locale *)((Uint8 *)retval + ((num_locales + 1) * sizeof(SDL_Locale *)));
loc = (SDL_Locale *)(retval + (num_locales + 1));
ptr = (char *)(loc + num_locales);
SDL_memcpy(ptr, csv, slen);