- Sep 29, 2004
- 18,656
- 68
- 91
-------------------- EDIT: The actual code:
Sorry, it is a bit different than in my OP.
Foo::Foo( ... ) {
// These are all class variables.
windowbtn=new MenuButton( ... );
minimizebtn=new Button( ... );
restorebtn=new Button( ... );
maximizebtn=new Button( ... );
}
// Destruct thrashes the pointers
Foo::~Foo(){
windowbtn=(MenuButton*)-1L;
minimizebtn=(Button*)-1L;
restorebtn=(Button*)-1L;
maximizebtn=(Button*)-1L;
}
------------------------ OP:
Well, 3 C/C++ guys coiuldn't figure out what someone did i nthe code we are looking at.
They new a pointer at one point in the code. So, assume a class called Foo. They have:
Foo *foo = new Foo();
Then later on when the want it later, they do not have this:
delete(foo);
Instead, they have:
foo = foo - 1;
The comment that coincides with this is "thrashing pointers".
The Google was powerless in my quest. So I ask you, AT forum member, to tell me what hte heck is going on. The odd thing is that from observing memory usage, I don't think there is a memory leak.
			
			Sorry, it is a bit different than in my OP.
Foo::Foo( ... ) {
// These are all class variables.
windowbtn=new MenuButton( ... );
minimizebtn=new Button( ... );
restorebtn=new Button( ... );
maximizebtn=new Button( ... );
}
// Destruct thrashes the pointers
Foo::~Foo(){
windowbtn=(MenuButton*)-1L;
minimizebtn=(Button*)-1L;
restorebtn=(Button*)-1L;
maximizebtn=(Button*)-1L;
}
------------------------ OP:
Well, 3 C/C++ guys coiuldn't figure out what someone did i nthe code we are looking at.
They new a pointer at one point in the code. So, assume a class called Foo. They have:
Foo *foo = new Foo();
Then later on when the want it later, they do not have this:
delete(foo);
Instead, they have:
foo = foo - 1;
The comment that coincides with this is "thrashing pointers".
The Google was powerless in my quest. So I ask you, AT forum member, to tell me what hte heck is going on. The odd thing is that from observing memory usage, I don't think there is a memory leak.
 
				
		 
			 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		
 Facebook
Facebook Twitter
Twitter