commit 6345a9bdee69210df5979bac2ea766a25ea1f613
Author: Fabian Greffrath <fabian@greffrath.com>
AuthorDate: Tue Nov 17 11:13:31 2015 +0100
Commit: Fabian Greffrath <fabian@greffrath.com>
CommitDate: Tue Nov 17 11:13:31 2015 +0100
Do not blindly assume single-byte framebuffers
---
src/doom/am_map.c | 2 +-
src/doom/f_wipe.c | 8 ++++----
src/doom/r_draw.c | 4 ++--
src/doom/st_stuff.c | 2 +-
src/i_video.c | 2 +-
src/v_video.c | 4 ++--
6 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/doom/am_map.c b/src/doom/am_map.c
index c9a4eb58..76acd8d4 100644
--- a/src/doom/am_map.c
+++ b/src/doom/am_map.c
@@ -833,7 +833,7 @@ void AM_Ticker (void)
//
void AM_clearFB(int color)
{
- memset(fb, color, f_w*f_h);
+ memset(fb, color, f_w*f_h*sizeof(*fb));
}
diff --git a/src/doom/f_wipe.c b/src/doom/f_wipe.c
index 3c204e05..73d40637 100644
--- a/src/doom/f_wipe.c
+++ b/src/doom/f_wipe.c
@@ -67,7 +67,7 @@ wipe_initColorXForm
int height,
int ticks )
{
- memcpy(wipe_scr, wipe_scr_start, width*height);
+ memcpy(wipe_scr, wipe_scr_start, width*height*sizeof(*wipe_scr));
return 0;
}
@@ -138,7 +138,7 @@ wipe_initMelt
int i, r;
// copy start screen to main screen
- memcpy(wipe_scr, wipe_scr_start, width*height);
+ memcpy(wipe_scr, wipe_scr_start, width*height*sizeof(*wipe_scr));
// makes this wipe faster (in theory)
// to have stuff in column-major format
@@ -234,7 +234,7 @@ wipe_StartScreen
int width,
int height )
{
- wipe_scr_start = Z_Malloc(SCREENWIDTH * SCREENHEIGHT, PU_STATIC, NULL);
+ wipe_scr_start = Z_Malloc(SCREENWIDTH * SCREENHEIGHT * sizeof(*wipe_scr_start), PU_STATIC, NULL);
I_ReadScreen(wipe_scr_start);
return 0;
}
@@ -246,7 +246,7 @@ wipe_EndScreen
int width,
int height )
{
- wipe_scr_end = Z_Malloc(SCREENWIDTH * SCREENHEIGHT, PU_STATIC, NULL);
+ wipe_scr_end = Z_Malloc(SCREENWIDTH * SCREENHEIGHT * sizeof(*wipe_scr_end), PU_STATIC, NULL);
I_ReadScreen(wipe_scr_end);
V_DrawBlock(x, y, width, height, wipe_scr_start); // restore start scr.
return 0;
diff --git a/src/doom/r_draw.c b/src/doom/r_draw.c
index 9271bcd5..4a7679f3 100644
--- a/src/doom/r_draw.c
+++ b/src/doom/r_draw.c
@@ -843,7 +843,7 @@ void R_FillBackScreen (void)
if (background_buffer == NULL)
{
- background_buffer = Z_Malloc(SCREENWIDTH * (SCREENHEIGHT - SBARHEIGHT),
+ background_buffer = Z_Malloc(SCREENWIDTH * (SCREENHEIGHT - SBARHEIGHT) * sizeof(*background_buffer),
PU_STATIC, NULL);
}
@@ -928,7 +928,7 @@ R_VideoErase
if (background_buffer != NULL)
{
- memcpy(I_VideoBuffer + ofs, background_buffer + ofs, count);
+ memcpy(I_VideoBuffer + ofs, background_buffer + ofs, count * sizeof(*I_VideoBuffer));
}
}
diff --git a/src/doom/st_stuff.c b/src/doom/st_stuff.c
index 9e96cd23..93665be2 100644
--- a/src/doom/st_stuff.c
+++ b/src/doom/st_stuff.c
@@ -1430,6 +1430,6 @@ void ST_Stop (void)
void ST_Init (void)
{
ST_loadData();
- st_backing_screen = (byte *) Z_Malloc(ST_WIDTH * ST_HEIGHT, PU_STATIC, 0);
+ st_backing_screen = (byte *) Z_Malloc(ST_WIDTH * ST_HEIGHT * sizeof(*st_backing_screen), PU_STATIC, 0);
}
diff --git a/src/i_video.c b/src/i_video.c
index 17d28897..b98c3667 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1020,7 +1020,7 @@ void I_FinishUpdate (void)
//
void I_ReadScreen (byte* scr)
{
- memcpy(scr, I_VideoBuffer, SCREENWIDTH*SCREENHEIGHT);
+ memcpy(scr, I_VideoBuffer, SCREENWIDTH*SCREENHEIGHT*sizeof(*scr));
}
diff --git a/src/v_video.c b/src/v_video.c
index 30521c4a..3789de38 100644
--- a/src/v_video.c
+++ b/src/v_video.c
@@ -110,7 +110,7 @@ void V_CopyRect(int srcx, int srcy, byte *source,
for ( ; height>0 ; height--)
{
- memcpy(dest, src, width);
+ memcpy(dest, src, width * sizeof(*dest));
src += SCREENWIDTH;
dest += SCREENWIDTH;
}
@@ -520,7 +520,7 @@ void V_DrawBlock(int x, int y, int width, int height, byte *src)
while (height--)
{
- memcpy (dest, src, width);
+ memcpy (dest, src, width * sizeof(*dest));
src += width;
dest += SCREENWIDTH;
}