I am brand spankin new to HLA.
I have been trying to get some OOP code working and have been mostly successful. The only lingering concern I have is that mem.isInHeap never seems to pass the conditional block in my destructor.

Relevant Constructor Code:


begin create;
// If the object has not had stack space allocated,
// then allocate some stack space and create its vmt.
dbg.put("Inside Constructor...");
if(esi=0) then
push(eax);
mov(mem.alloc(@size(tWindow)),esi);
pop(eax);
endif;
// Initialize the virtual method table...
mov(&tWindow._VMT_, this._pVMT_);
// Initialize all the member variables...


Relevant Destructor Code:


begin destroy;
dbg.put("Inside Destructor...");
push(eax); // Preserve eax
// If the object is allocated on the stack, blow it away
if(mem.isInHeap(esi)) then
dbg.put(" - Free the stack!"); //<----- The line in question
mem.free(esi);
endif;
pop(eax); // Restore eax


My worry is that the debug statement in the conditional is never called.

Ideas?
~Nick
Posted on 2004-09-21 17:09:08 by SowWn
I am brand spankin new to HLA.
I have been trying to get some OOP code working and have been mostly successful. The only lingering concern I have is that mem.isInHeap never seems to pass the conditional block in my destructor.


Ideas?
~Nick


mem.isInHeap seems to be broken.
I'll fix that for HLA v1.71.
Cheers,
Randy Hyde
Posted on 2004-09-26 22:39:15 by rhyde
I am brand spankin new to HLA.
I have been trying to get some OOP code working and have been mostly successful. The only lingering concern I have is that mem.isInHeap never seems to pass the conditional block in my destructor.


Ideas?
~Nick


mem.isInHeap seems to be broken.
I'll fix that for HLA v1.71.
Cheers,
Randy Hyde


BTW, if you need the fix right away, here's the new version of mem.isInHeap to use:



procedure mem.isInHeap( memptr: dword ); @nodisplay;
begin isInHeap;

push( ebx );
push( ecx );
push( edx );
mov( listHead, ebx );
mov( memptr, edx );
mov( NULL, eax );
while( ebx <> NULL ) do

mov( (type memblock [ebx]).size, ecx );
add( ebx, ecx );
add( @size( memblock ), ebx );

if( edx >= ebx && edx < ecx ) then

// Pointer is within the current block,
// return a pointer to the start of the
// data area, but only if it's currently
// allocated:

if( (type memblock [ebx-@size( memblock )]).refCount > 0 ) then

mov( ebx, eax );

// else return NULL

endif;
break;

endif;

// Move on to the next block:

mov( (type memblock [ebx-@size( memblock )]).next, ebx );

endwhile;
pop( edx );
pop( ecx );
pop( ebx );

end isInHeap;

Cheers,
Randy Hyde
Posted on 2004-09-26 22:52:23 by rhyde
Many Thanks,

I will try this when i get home from work ;)

~Nick
Posted on 2004-09-27 15:05:56 by SowWn