Jump to content


ID3DXBaseEffect::GetString Question


2 replies to this topic

#1 dega512

    Valued Member

  • Members
  • PipPipPip
  • 108 posts

Posted 07 July 2007 - 11: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???



#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 4782 posts
  • LocationBellevue, WA

Posted 08 July 2007 - 12:34 AM

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.
reedbeta.com - developer blog, OpenGL demos, and other projects

#3 dega512

    Valued Member

  • Members
  • PipPipPip
  • 108 posts

Posted 08 July 2007 - 12:35 AM

That's what I was suspecting, but I figured that I would rather be safe than sorry :happy: .





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users