#include "stdafx.h" #include "midl_alloc.h" /// /// The midl_user_allocate function is a function that client and server applications provide to allocate memory. /// /// Specifies the count of bytes to allocate. /// If midl_user_allocate fails to allocate memory, it must return a NULL pointer. void* __RPC_USER midl_user_allocate(size_t size) { void* address = malloc(size); if (address != 0) { // Zero fill for safety memset(address, 0, size); } return address; } /// /// The midl_user_free function is provided by client and server applications to deallocate dynamically allocated memory. /// /// A pointer to the memory block to be freed. void __RPC_USER midl_user_free(void* p) { // Free would throw an error on null pointer. If we check it here, user code can kept simpler. if (p != nullptr) { free(p); } }