Ok, thanks.

I was considering the first approach. My app does have a 'global' structure
(it is not a global, but I call it one anyway) that is allocated in the
beginning. I was considering creating a sub sctructure to handle this misfit
globals.

I do use sysAppLaunch to launch my application with a non-normal launch
code. Could it be that the launch code is non-normal so the system does not
allow the globals?

Thanks,
Donald


"Logan Shaw" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Donald C. Kirker wrote:
> > I am working on an application that can handle launch codes such as
> > sysAppLaunchCmdGoToURL. I can properly launch the application with these
> > calls and it works just fine (all globals, not many of them, appear to
> > work),
>
> Just because they appear to work doesn't mean that it's safe to use
> globals.  I'm not saying it isn't safe, but since globals basically
> are just memory indexed by a register, it's quite possible that
>
> > but just after my AppStop code (ApplicationStop) is called, a
> > "MemoryMgr.c, Line:3650, Non-word-aligned handle" error is thrown. Right
now
> > I am using: SysUIAppSwitch (cardNo, dbID, sysAppLaunchCmdGoToURL, urlP);
to
> > launch the application.
>
> Well, in general, you don't have access to globals unless you are run
> with the sysAppLaunchCmdNormalLaunch launch code[1].  So, I wouldn't
> be surprised if this is failing.  If you aren't being given globals and
> you're trying to access them anyway, it could be that you're overwriting
> some memory that you don't own, and it's not out of the question that
> that memory is being overwritten by something else as well.  I wouldn't
> be surprised if one of your pointers (or handles) is being trashed
> because of this and you find out when you try to use the handle to
> free some memory.
>
> In your situation, I guess the first thing I'd do is check the launch
> flags to see if the sysAppLaunchFlagNewGlobals.  Although my experience
> indicates you do not ALWAYS have globals when this flag is set (due to,
> I think bugs on a few devices, although it might be a misunderstanding
> on my part), it's still right most of the time and should probably help
> you confirm whether you do have globals available or not.
>
> If you find you don't have globals available, which is what I think you
> will find, there are two obvious approaches:
> (a) restructure app to eliminate all globals; if all else fails, you
>      can always put them all into a struct, allocate that using
>      MemPtrNew() very early on, and pass a pointer to that struct
>      around on the stack.  There are cleaner approaches, but that
>      is the brute force way.
> (b) do the trick where you relaunch yourself using SysAppLaunch(),
>      causing yourself to get globals in the process.  I don't think
>      it's supported to set the sysAppLaunchFlagNewGlobals flag
>      when you call SysAppLaunch(), but I'm fairly sure it does work.
>      This is, obviously, the super-easy low-impact method of getting
>      things to work:  you *force* the system to give you globals.
>      Note that SysAppLaunch() calls runs app as basically a subroutine,
>      so it blocks until the app exits.  This is different from how
>      SysUIAppSwitch() works.
>
> Hope that helps.
>
>    - Logan
>
> [1] The Programmer's Companion says you can also sometimes have globals
>      when you're launched with sysAppLaunchCmdURLParams, but only with
>      certain URLs (weird).  But that's not the launch code you mentioned
>      anyway, so it doesn't seem relevant.
>



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

Reply via email to