X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/9a30e26b7801d63e4ccfe8d36169299c09b89dff..3d88e64dfcf5dc0fd361ce0c504c67a9196ce44c:/window.c diff --git a/window.c b/window.c index effa2deb..5d6b2cf3 100644 --- a/window.c +++ b/window.c @@ -600,7 +600,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) { char *bits; int size = (font_width + 15) / 16 * 2 * font_height; - bits = smalloc(size); + bits = snewn(size, char); memset(bits, 0, size); caretbm = CreateBitmap(font_width, font_height, 1, 1, bits); sfree(bits); @@ -999,6 +999,10 @@ static void init_palette(void) HDC hdc = GetDC(hwnd); if (hdc) { if (cfg.try_palette && GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) { + /* + * This is a genuine case where we must use smalloc + * because the snew macros can't cope. + */ logpal = smalloc(sizeof(*logpal) - sizeof(logpal->palPalEntry) + NCOLOURS * sizeof(PALETTEENTRY)); @@ -1723,7 +1727,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, if ((lParam - IDM_SAVED_MIN) / 16 < sesslist.nsessions) { char *session = sesslist.sessions[(lParam - IDM_SAVED_MIN) / 16]; - cl = smalloc(16 + strlen(session)); + cl = snewn(16 + strlen(session), char); /* 8, but play safe */ if (!cl) cl = NULL; @@ -2531,7 +2535,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, if (n > 0) { int i; - buff = (char*) smalloc(n); + buff = snewn(n, char); ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, buff, n); /* * Jaeyoun Chung reports that Korean character @@ -2719,7 +2723,7 @@ void do_text(Context ctx, int x, int y, char *text, int len, int i; if (len > IpDxLEN) { sfree(IpDx); - IpDx = smalloc((len + 16) * sizeof(int)); + IpDx = snewn(len + 16, int); IpDxLEN = (len + 16); } for (i = 0; i < IpDxLEN; i++) @@ -2850,7 +2854,8 @@ void do_text(Context ctx, int x, int y, char *text, int len, int nlen, mptr; if (len > uni_len) { sfree(uni_buf); - uni_buf = smalloc((uni_len = len) * sizeof(wchar_t)); + uni_len = len; + uni_buf = snewn(uni_len, wchar_t); } for(nlen = mptr = 0; mptr