According to http://msdn.microsoft.com/en-us/library/bb173057(VS.85).aspx and http://msdn.microsoft.com/en-us/library/bb173056(VS.85).aspx, these functions return a pointer to a string. However, in all the examples I've seen on the web, they directly use the return value without freeing it afterward.
For example:
char buf[2048];
sprintf(buf, "Error: %s error description: %s\n",DXGetErrorString(hr),DXGetErrorDescription(hr));
Does that mean there is a memory leak because the memory allocated for the error string and the error description is never released? If not, how is it released?
Most likely, the functions return a static string, so it doesn't need to be free'd.
It'd be similar to writing code like this, where you would not worry about freeing the return value:
PCWSTR GetErrorCode(int error)
{
switch (error)
{
case 1:
return L"File not found";
...
default:
return "Unknown error";
}
}