Re: [PATCH 4/5] reg: Use a helper function to allocate and re-allocate memory
Hugh McMaster <hugh.mcmaster(a)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(a)winehq.org
participants (1)
-
Alexandre Julliard