Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.

Ronin Magus

Deleting pointers

This topic is 5753 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Do I have to delete a pointer that does not point to a new item on the stack? I need to brush up on my pointers Well I've got a vector and a pointer is declared to point to an item in the vector, but no new data is being allocated for the pointer. I think I don't have to delete it but I'm just making sure by asking. Just my code to look at:
struct SG_Window
SG_WindowRef ref;
bool (*fpEventHandler) (SG_WindowRef, SG_Message, Uint32, Uint32);


SG_Window * SG_GetWindowByRef(SG_WindowRef ref)
// returns a pointer to a window by searching for its reference

  if(ref != 0)
    for(int i = 0; i < SG_WindowList.size(); i++)
       if(SG_WindowList[i].ref == ref)
         return &SG_WindowList[i];

  return NULL;

bool SG_HandleMessage(SG_WindowRef ref, SG_Message msg, Uint32 data, Uint32 extra)
  SG_Window * target;

  if (ref)
    target = SG_GetWindowByRef(ref);

    if(target != NULL && target->fpEventHandler(ref, msg, data, extra))
      return true;

  [handle system messages, return true if handled ...]

  cout << "Unhandled message: " << msg << endl;
  cout << "Sent to window: " << ref << endl;

  return false;

There's a lot more but I just pasted what was important. Basically I'm wondering if I need to delete SG_Window * target in function SG_HandleMessage. http://roninmagus.hopto.org acronymfinder.com - Find any acronym you need! [edited by - Ronin Magus on October 22, 2002 7:39:55 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!