PDA

View Full Version : ID3DXBaseEffect::GetString Question


dega512
07-07-2007, 04:43 PM
This is probably a silly question, but I can't seem to find the answer on Google or MSDN.

Here is my question:

Do I have to delete the pointer to the string given to me by ID3DXBaseEffect::GetString, or is it deleted when I release the effect?

i.e.


ID3DXEffect *pEffect = ...; // would be pointing to the loaded effect
D3DXHANDLE strHandle = ...; // would be pointing to the string parameter
LPCSTR strValue;

if (FAILED(pEffect->GetString(strHandle, &strValue)))
{
// handle the error
}

// do something with 'strValue'

delete strValue; // do I need this???

Reedbeta
07-07-2007, 05:34 PM
Most likely it returns a pointer into an internal structure someplace that is managed by D3DX. I doubt you need to delete it yourself.

The corollary to that: if you want to modify the string, you of course shouldn't do it through the pointer returned (the pointer is const so you can't do this without a cast, anyway), but rather duplicate the string into your own buffer first.

dega512
07-07-2007, 05:35 PM
That's what I was suspecting, but I figured that I would rather be safe than sorry :happy: .