Skip to content

Commit

Permalink
Simpler pointer arithmetic
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jul 19, 2024
1 parent f4eded4 commit c049b4f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/camera/SDL_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down
2 changes: 1 addition & 1 deletion src/locale/SDL_locale.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit c049b4f

Please sign in to comment.