adamdebreceni commented on a change in pull request #928:
URL: https://github.com/apache/nifi-minifi-cpp/pull/928#discussion_r509023703
##########
File path: extensions/windows-event-log/wel/WindowsEventLog.cpp
##########
@@ -43,10 +45,10 @@ void WindowsEventLogMetadataImpl::renderMetadata() {
const auto contextGuard = gsl::finally([&context](){
EvtClose(context);
});
- if (!EvtRender(context, event_ptr_, EvtRenderEventValues, dwBufferSize,
nullptr, &dwBufferUsed, &dwPropertyCount)) {
+ if (!EvtRender(context, event_ptr_, EvtRenderEventValues, dwBufferSize,
rendered_values.get(), &dwBufferUsed, &dwPropertyCount)) {
if (ERROR_INSUFFICIENT_BUFFER == (status = GetLastError())) {
dwBufferSize = dwBufferUsed;
- rendered_values = std::unique_ptr<EVT_VARIANT,
utils::FreeDeleter>((PEVT_VARIANT)(malloc(dwBufferSize)));
+ rendered_values.reset((PEVT_VARIANT)(malloc(dwBufferSize)));
Review comment:
if you check all api calls, you can see that it first assigns the
required buffer size (here `dwBufferUsed `) to the variable storing the actual
buffer size (here `dwBufferSize `) and then calls `malloc` with the actual
buffer size (modulo if it is in bytes or chars)
do you think it would be an improvement in readability if we allocate based
on the required buffer size and then assign it to the actual buffer size?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]