On Tue, Feb 26, 2002 at 11:38:19AM +0100, Pascal Levy wrote:
> There is also a similar problem with SysQSort : if the callback you supply
> throws an exception, the temporary stack allocated in SysQSort is never
> freed, since control returns directly to your code. A very simple
> improvement would be that SysQSort catch the exception, clean up, and
> rethrow it.

What's an exception?

No, really :-) -- CodeWarrior and GCC both have their own ways of
implementing C++ exceptions, and their implementations may even change
in the future.  Because implementations of these things on m68k Palm OS
vary, it's not practical to burn knowledge of them into the Palm OS ROM.
That's why the current Palm OS API is a C API: it's (modulo bugs in the
ABI, such as it is :-() the lowest common denominator across the tools
used to build Palm OS applications.

Throwing exceptions back through an OS function is not a very good idea
and in fact is probably undefined (?).  The way to handle this is not to
allow an exception to escape from your comparison function, but to signal
the failure back to the caller some other way, such as via SysQSort()'s
_other_ parameter.  Such is life when you're calling a C function.

Thus you avoid this memory leak on existing ROMs now.  No "improvements"
needed.

    John

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

Reply via email to