Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pointer help

Status
Not open for further replies.

Pyramus

Programmer
Dec 19, 2001
237
GB
for (int i=0; i<lLength; i++)
{
hr = Function(i, &pNode);

//do stuff with pNode
}

Is the Code above ok in principle?

Do I need to do anything to pNode before I call Function again, or will it be ok?
 
What is pNode??
It all depends on what you do with the information in pNode. Otherwise, the function is syntactically legal.

Or... is it an array of pointers you want to iterate? In that loop you'll be doing the same operation <length> times on pNode. [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
pNode is a smart pointer. Function returns it as a reference to that pointer.
 
Again... it all depends on what you want to do with that pointer, be it smart or not.
It depends also on the behavior of... well... it depends on how smart is it, when it kilss himself anso, based on the documentation of the library you're using.

But, if not declared inside the loop, the pointer should not go out of scope and commit suicide, so it should be ok.
I'm interested also in other opinions so anybody should feel free to smash me if I'm wrong. [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
Hey... have you found the cause for that memory leak that you were getting when using threads?

I get a similar situation when creating just one worker thread:
thrdcore.cpp(166) : {73} client block at 0x00431320, subtype 0, 112 bytes long..

Is this similar to your messages? [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
I think I've sorted it. I'm never going to develop for NT4 again. What platform are you developing for?
 
win2000. What was wrong? [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
Well to be honest, nothing glaringly obvious at all, in fact I'm still not completely sure what was causing it.

I changed a few things, including turning Speed Optimisation off in the build setting, manually newing and deleting objects instead of relying on their constructors/destructors and other small things like trying to avoid wrapper classes where I could, eg. CComBSTR.

Really annoying, wasted 2 weeks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top