From d15ab96a51287469082e8d9068e2608a386f9e5f Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 17 Mar 2016 21:55:12 +0000 Subject: Fix size_t printf formatting The printf formatting for size_t is set in c99 as %zu but in windows it is %Iu this is solved by adding and inttypes style PRI macro for size_t This also uses this macro everywhere size_t is formatted. --- windows/bitmap.c | 17 ++++++++++++----- windows/window.c | 10 +++++----- 2 files changed, 17 insertions(+), 10 deletions(-) (limited to 'windows') diff --git a/windows/bitmap.c b/windows/bitmap.c index 68dd955dd..e86f95bfe 100644 --- a/windows/bitmap.c +++ b/windows/bitmap.c @@ -57,6 +57,7 @@ void *win32_bitmap_create(int width, int height, unsigned int state) if (pbmi == NULL) { return NULL; } + pbmi->bV5Size = sizeof(BITMAPV5HEADER); pbmi->bV5Width = width; pbmi->bV5Height = -height; @@ -71,7 +72,6 @@ void *win32_bitmap_create(int width, int height, unsigned int state) windib = CreateDIBSection(NULL, (BITMAPINFO *)pbmi, DIB_RGB_COLORS, (void **)&pixdata, NULL, 0); - if (windib == NULL) { free(pbmi); return NULL; @@ -286,11 +286,13 @@ struct bitmap *bitmap_scale(struct bitmap *prescale, int width, int height) * transfer */ if (ret == NULL) return NULL; + retpixdata = malloc(width * height * 4); if (retpixdata == NULL) { free(ret); return NULL; } + inpixdata = (uint32_t *)prescale->pixdata; ret->pixdata = (uint8_t *)retpixdata; ret->height = height; @@ -307,8 +309,11 @@ struct bitmap *bitmap_scale(struct bitmap *prescale, int width, int height) } -struct bitmap *bitmap_pretile(struct bitmap *untiled, int width, int height, - bitmap_flags_t flags) +struct bitmap * +bitmap_pretile(struct bitmap *untiled, + int width, + int height, + bitmap_flags_t flags) { struct bitmap *ret = malloc(sizeof(struct bitmap)); if (ret == NULL) @@ -352,7 +357,8 @@ struct bitmap *bitmap_pretile(struct bitmap *untiled, int width, int height, return ret; } -static nserror bitmap_render(struct bitmap *bitmap, struct hlcache_handle *content) +static nserror +bitmap_render(struct bitmap *bitmap, struct hlcache_handle *content) { int width; int height; @@ -368,7 +374,8 @@ static nserror bitmap_render(struct bitmap *bitmap, struct hlcache_handle *conte height = ((width * bitmap->height) + (bitmap->width / 2)) / bitmap->width; - LOG("bitmap %p for content %p width %d, height %d", bitmap, content, width, height); + LOG("bitmap %p for content %p width %d, height %d", + bitmap, content, width, height); /* create two memory device contexts to put the bitmaps in */ bufferdc = CreateCompatibleDC(NULL); diff --git a/windows/window.c b/windows/window.c index 455e6e5f5..d3f2c99c5 100644 --- a/windows/window.c +++ b/windows/window.c @@ -1451,16 +1451,16 @@ win32_window_update_box(struct gui_window *gw, const struct rect *rect) -static void win32_window_get_dimensions(struct gui_window *w, int *width, int *height, +static void win32_window_get_dimensions(struct gui_window *gw, int *width, int *height, bool scaled) { - if (w == NULL) + if (gw == NULL) return; - LOG("get dimensions %p w=%d h=%d", w, w->width, w->height); + LOG("get dimensions %p w=%d h=%d", gw, gw->width, gw->height); - *width = w->width; - *height = w->height; + *width = gw->width; + *height = gw->height; } static void win32_window_update_extent(struct gui_window *w) -- cgit v1.2.3