I'm developing tools at work, where we have some Palms with OS 2.0.  I've
discovered the bug in SetSetReceiveBuffer which states:

A bug was introduced in Palm OS 2.0 that can cause various problems when you
pass a zero length buffer into SerSetReceiveBuffer.
---------------
"When calling SerSetReceiveBuffer with a zero length buffer, it is supposed
to restore the default buffer. Instead, it changes the owner of your buffer
to the system. This can cause the following problems:

You will no longer be able to set a static buffer since this call requires
the buffer be an allocated block.  If your app does not free the block
correctly, it will never be freed since it now belongs to the system. After
an app restores the default buffer, the default buffer cannot be used
because it will be freed when the application exits. Trying to use the
default buffer will result in heap corruption. You can work around this bug
by ensuring that you close the serial library by calling SerClose when your
application exits. "
----------------
My app does call SerClose, but after calling SerSetReceiveBuffer with a
length of zero, as required:  (from the 3.0 SDK reference doc)
----------------
"To restore the default receive queue, call SerSetReceiveBuffer passing 0
(zero) for the buffer
size. The serial manager does not free the custom receive queue."
----------------
I figured that I would try to set the Receive buffer with allocated heap mem
as stated in the 2.0 bug report, and skip the closing SerSetReceiveBuffer
call if the OS was 2.0.  But, when I attempt to SerSetReceiveBuffer after
getting a sysAppLaunchCmdNormalLaunch, and creating the buffer, I get a "VSM
0.3 has just written to Low Memory" error from the emulator.

So, OS 2.0 won't handle a static buffer, but won't let me use a dynamically
allocated buffer.  Further, it appears that not restoring the default buffer
at SerClose will cause a memory leak.

What am I missing?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Joe Wronski      FitSense Technology           [EMAIL PROTECTED]
                                      Also at: [EMAIL PROTECTED]
http://www.fitsense.com       And: http://home.earthlink.net/~jwronski
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Reply via email to