> I am building a framework where an outside source (another coder) is
passing
> me a pointer. Right now, the only way I can check if the pointer is valid
> is by calling MemPtrSize(). If the pointer is very weird (not a valid
> chunk) the OS displays a fatal message and resets.
i have built a framework which has plugin modules - (www.drcompanion.com)
so, i can provide some assistance/guidance here :)
solution #1:
------------
struct
{
void *ptr;
UInt32 ptrSize;
} ptrData;
get the developer to pass you a pointer to that structure instead :)
no need to do anything fancy, all data is stored (hope he set it
right) :P
solution #2:
------------
you cannot call MemPtrSize() on any pointer. you need to determine
if it is actually a dynamic pointer (allocated using MemPtrNew) or
a static pointer (MemHandleLock()). there is a way to do this, i
dont recall it off hand, but, once you determine if it is a handle
or dynamic chunk, you can use:
MemPtrSize(ptr);
MemHandleSize(MemPtrRecoverHandle(ptr));
/me checks API references.. bbiab :)
>> MemPtrDataStorage
> I would prefer to handle this error gracefully by returning an error
> code. If there a way that MemPtrSize (or similar calls) can return
> as opposed to display window then resetting?
need to know if it is a pointer of handle :)
> In this case, I am not actually allocating the memory. I am just
> trying to keep the users of the framework safe.
try solution #1 - its safe, and, since you are developing the framework,
you can define the interface :) it'll still be a pointer, but, in this
case, a pointer to a pointer with a little extra info (size) :P
hope this helps.
---
Aaron Ardiri [EMAIL PROTECTED]
CEO - CTO +46 70 656 1143
Mobile Wizardry http://www.mobilewizardry.com/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/