You can also write your own modifications of all allocation functions such
as e.g.

void* XMemPtrNew( long size )
{
 void* n = MemChunkNew( 0, size, memNewChunkFlagNonMovable );
 if( n != NULL )
  MemPtrSetOwner( (MemPtr)n, GetHeapOwner() ) ;
 return n;
}

Same way for MemHandleNew and think whether you use MemHandle/PtrResize.
Then write GetHeapOwner() to provide the requested functionality.

You don't need to rewrite the old code - simply use #define statements to
redefine meaning of the original MemPtrNew etc.

This will work for your allocations - not for those done by the system.

Regards,
    Jan Slodicka


----- Original Message ----- 
From: "Tony Yat-Tung Cheung" <[EMAIL PROTECTED]>
Newsgroups: palm-dev-forum
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Cc: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Friday, July 30, 2004 8:18 AM
Subject: Re: SysUIAppSwitch()


> Ben Combee wrote:
>
> > At 09:30 AM 7/29/2004, you wrote:
> >
> >> >Yes. When you pass a pointer to SysUIAppSwitch, you've given control
> >> of it
> >> >to the OS, and the OS is responsible for deallocating it. That's why
> >> it's
> >> >important to set the owner to 0 -- otherwise, the system routine that
> >> frees
> >> >all of the memory allocated by a program when it ends would free this
> >> block
> >> >before the new program is called.
> >>
> >> Yes. Other than using MemPtrSetOwner(ptr, 0), is there any other way
> >> to disable the OS from freeing the memory allocated by a program when
> >> it ends?
> >
> >
> > No.  This memory free is done as a standard part of the OS's
> > application-switch code.
>
> Thank you.
>
> Thinking in another direction, is it possible to use owner ID of zero in
> an application? Then an application simply needs to switch to use the
> owner ID zero, before allocating memories which should persist after the
> application quits.
>
> I am searching for the solution, since I have cases that I do not have
> access to the internal of the structure, but I want to persist them when
> the application quits, such as the SslContext.
>
> Anyone? Thank you.
>
> Tony
>
> -- 
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to