Re: [PATCH 2/7] regedit: Use FormatMessage() for optimal memory usage (v2)
Hugh McMaster <hugh.mcmaster(a)outlook.com> writes:
Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com> --- programs/regedit/edit.c | 14 +++++++++----- programs/regedit/regedit.rc | 12 ++++++------ 2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/programs/regedit/edit.c b/programs/regedit/edit.c index a223535..3f2b7a4 100644 --- a/programs/regedit/edit.c +++ b/programs/regedit/edit.c @@ -49,15 +49,19 @@ struct edit_params static INT vmessagebox(HWND hwnd, INT buttons, INT titleId, INT resId, va_list ap) { WCHAR title[256]; - WCHAR errfmt[1024]; - WCHAR errstr[1024]; + WCHAR fmt[1024]; + WCHAR *str; + int ret;
LoadStringW(hInst, titleId, title, COUNT_OF(title)); - LoadStringW(hInst, resId, errfmt, COUNT_OF(errfmt)); + LoadStringW(hInst, resId, fmt, COUNT_OF(fmt));
- vsnprintfW(errstr, COUNT_OF(errstr), errfmt, ap); + FormatMessageW(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ALLOCATE_BUFFER, + fmt, 0, 0, (WCHAR *)&str, 0, &ap); + ret = MessageBoxW(hwnd, str, title, buttons); + LocalFree(str);
- return MessageBoxW(hwnd, errstr, title, buttons); + return ret; }
You have to use __ms_va_list with FormatMessage. Check how this is done in regedit.c. -- Alexandre Julliard julliard(a)winehq.org
On 1 Feb 2017, at 9:44 pm, Alexandre Julliard wrote:
You have to use __ms_va_list with FormatMessage. Check how this is done in regedit.c.
Sorry. I completely forgot about using __ms_va_list and friends. I've resent the patch series. -- Hugh McMaster
participants (2)
-
Alexandre Julliard -
Hugh McMaster