Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


reseting pointer variable - how?

Posted on 2007-07-27
Medium Priority
Last Modified: 2010-04-01
I have a pointer IplImage* HSVIMage = 0; //declaration

I process the image in my thread and do some stuff to it. I am now done with it. Later in the thread I want to overwrite the image and reuse it. How do I "reset" the pointer variable for reuse? I tried releasing it ReleaseImage( &HSVIMage) and redeclaring it, but then I get a multiple reinitialization error when compiling. Is it even necessary to "reuse" it?

Question by:Wanderinglazyeye
  • 2
LVL 53

Expert Comment

ID: 19581891
Once it's released, it's best to set the pointer to 0, and then it's ready for use again, without having to re-declare it.
LVL 53

Accepted Solution

Infinity08 earned 2000 total points
ID: 19581902
So, something like :

        IplImage* HSVIMage = 0;
        // create image
        // use image
        // release image
        HSVIMage = 0;

and now you can create the image again, etc. You don't have to re-use it though - you won't win anything, because you already released the memory that was allocated to the pointer.

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question