[PATCH 4/5] reg: Use a helper function to allocate and re-allocate memory
Alexandre Julliard
julliard at winehq.org
Mon Jul 24 09:43:47 CDT 2017
Hugh McMaster <hugh.mcmaster at outlook.com> writes:
> @@ -174,6 +177,26 @@ static BOOL ask_confirm(unsigned int msgid, WCHAR *reg_info)
> }
> }
>
> +#define CHECK_ENOUGH_MEMORY(p) \
> +if (!(p)) \
> +{ \
> + output_message(STRING_OUT_OF_MEMORY, __FILE__, __LINE__); \
> + exit(1); \
> +}
> +
> +static void *resize_buffer(void *buf, size_t count)
> +{
> + void *new_buf;
> +
> + if (buf)
> + new_buf = HeapReAlloc(GetProcessHeap(), 0, buf, count);
> + else
> + new_buf = HeapAlloc(GetProcessHeap(), 0, count);
> +
> + CHECK_ENOUGH_MEMORY(new_buf);
> + return new_buf;
> +}
The macro is not needed, and the message doesn't need to be localized,
since this would require allocating memory. I think you'll also want a
separate wrapper for HeapAlloc.
--
Alexandre Julliard
julliard at winehq.org
More information about the wine-devel
mailing list