Earlier, you wrote:
In my caller palm application, i included the header for a class A and declared a pointer to A at where I need to use this class. It seems I can call a shared lib function like CreateObjA to return an A object pointer, but when I pass this pointer back to an A member method wrapped in my lib, which meant to set a boolean type member variable of this A object, my caller application crashes and the error message saying the lib function is trying to access either unallocated mem, or the mem which is not allowed to access.It seems to me like the object allocated by the lib function CreateObjA is deallocated out of the scope of the CreateObjA so that the pointer I get becomes invalid when I try to use it second time and thus cause memory errors. I don't know whether this is true and if the shared lib cann't hold the memory chuck allocated for the object within the library space, how can I work around this problem?
At 15:13 2003-1-6 -0500, you wrote:
OK.... CDateTime is a local class, but it is using functions in your shared library, right?The class I tried actually is a very simple one called CDateTime with only one public member variable DateTiemType _dateTime and a couple of member methods like "Int16 getDay()", " void setDate(const CDate rhs )" to manipulate the _dateTime. All the member methods are not virtual functions to me since they are all implemented in CDateTime class.
Objects allocated using new don't have a lifetime determined by the program -- they don't get destroyed until a matching delete call. Since new/delete use MemPtrNew/MemPtrFree, their pointers should be valid for the life of the program.
A Palm OS shared libraries is really just a chunk of code that's locked down in memory. The OS provides a simple dispatch mechanism to find the entry points into this code, but that's as far as the model goes. Effectively, anything done in a shared lib is done as if it were in the calling application.
Why not test things out a bit. Modify your classes constructor to put a sentinel value into the object, then inspect the object using the debugger after a call to create one of these. Make sure your pointer points to a real, constructed object. Once you've seen that, then try to build on it further.
--
Ben Combee <[EMAIL PROTECTED]>
CodeWarrior for Palm OS technical lead
Palm OS programming help @ www.palmoswerks.com
--
For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
