X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=windows%2Fwinutils.c;h=2e0183d37493817ae8e8bdb350a6358b02114361;hb=03cc84d3f3ec122b0787bf6e97d2e715f979f432;hp=40f1f4a7502054f6b66f9fe03a75c2edcb086c29;hpb=1dac1bc911bd76446f19c48fbca9c868c33f07ca;p=PuTTY.git diff --git a/windows/winutils.c b/windows/winutils.c index 40f1f4a7..2e0183d3 100644 --- a/windows/winutils.c +++ b/windows/winutils.c @@ -150,6 +150,25 @@ void pgp_fingerprints(void) HELPCTXID(pgp_fingerprints)); } +/* + * Handy wrapper around GetDlgItemText which doesn't make you invent + * an arbitrary length limit on the output string. Returned string is + * dynamically allocated; caller must free. + */ +char *GetDlgItemText_alloc(HWND hwnd, int id) +{ + char *ret = NULL; + int size = 0; + + do { + size = size * 4 / 3 + 512; + ret = sresize(ret, size, char); + GetDlgItemText(hwnd, id, ret, size); + } while (!memchr(ret, '\0', size-1)); + + return ret; +} + /* * Split a complete command line into argc/argv, attempting to do * it exactly the same way Windows itself would do it (so that