Skip to content

Commit b75d5ca

Browse files
committed
Drop unnecessary sizeof(uint32_t)
This commit replaces sizeof(uint32_t), which is always 4, with an explicit expression to copy stride data.
1 parent f177b5f commit b75d5ca

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

backend/fbdev.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ static void _twin_fbdev_put_span(twin_coord_t left,
5858
twin_coord_t width = right - left;
5959
off_t off = top * screen->width + left;
6060
uint32_t *dest =
61-
(uint32_t *) ((uintptr_t) tx->fb_base + (off * sizeof(uint32_t)));
62-
memcpy(dest, pixels, width * sizeof(uint32_t));
61+
(uint32_t *) ((uintptr_t) tx->fb_base + (off * sizeof(*dest)));
62+
memcpy(dest, pixels, width * sizeof(*dest));
6363
}
6464

6565
static void twin_fbdev_get_screen_size(twin_fbdev_t *tx,

backend/sdl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static void _twin_sdl_put_span(twin_coord_t left,
5050
}
5151
if ((top + 1 - tx->image_y) == tx->height) {
5252
SDL_UpdateTexture(tx->texture, NULL, tx->pixels,
53-
screen->width * sizeof(uint32_t));
53+
screen->width * sizeof(*pixels));
5454
SDL_RenderCopy(tx->render, tx->texture, NULL, NULL);
5555
SDL_RenderPresent(tx->render);
5656
}
@@ -157,8 +157,8 @@ twin_context_t *twin_sdl_init(int width, int height)
157157
goto bail;
158158
}
159159

160-
tx->pixels = malloc(width * height * sizeof(uint32_t));
161-
memset(tx->pixels, 255, width * height * sizeof(uint32_t));
160+
tx->pixels = malloc(width * height * sizeof(*tx->pixels));
161+
memset(tx->pixels, 255, width * height * sizeof(*tx->pixels));
162162

163163
tx->render = SDL_CreateRenderer(tx->win, -1, SDL_RENDERER_ACCELERATED);
164164
if (!tx->render) {

0 commit comments

Comments
 (0)