I have a driver that I am modifying that was written by someone else in C. Since I need to add some C++ function calls I am now building the driver with C++ compiler versus C compiler (in Visual Studio 2012). When I changed to C++ I received a lot of build errors, all of which I have been able to fix except for a few. The few errors are all related to calls to the same function. I have searched the web extensively to try to find a solution to this issue without any success. So below are the components to this issue that I hope will allow someone to help me with this issue.
First, here is the function that is being called. You may be wondering why the original S/W developer created their own custom free memory function when they could have just used the free() function in the standard C library. I do not know why this was but since it was working just fine, I hesitate to change it.
void freeMemory(void **pBuffer)
{
BOOL result;
ASSERT(pBuffer != NULL);
// see if buffer is already been freed
if (*pBuffer == NULL)
{
return;
}
result = VirtualFree(
*pBuffer, // LPVOID lpAddress, // address of memory
0, // SIZE_T dwSize, // size of memory
MEM_RELEASE // DWORD dwFreeType // operation type
);
// see of we were able to successfully free the memory
if (result == FALSE)
{
ASSERT(FALSE);
return;
}
// Mark the buffer pointer as now being free
*pBuffer = NULL;
}
So the next piece to this puzzle is a #define as follows:
#define FREE(pBuffer) freeMemory(&(pBuffer))
Finally, below is one of the many calls to this FREE function:
FREE(Buffer);
In this example, "Buffer" is a pointer to an unsigned char.
unsigned char *Buffer;
For reference purposes, the error that I am receiving, for this particular example, is "cannot convert parameter 1 from 'unsigned char *' to 'void **'"
It's been a long time since I have done much with straight C or C++ and pointers were never my strong suite. Based on the error, my assumption was that this error is related to not providing a cast in the function call, but considering how the free() function is used from the standard C library, it doesn't seem like this should be necessary. Any help on what I need to do with respect to how the FREE function is called to eliminate these errors would be greatly appreciated.