Actually, what I wanted to do is to evaluate an arbitrary Feature value to
determine if it was a pointer or just a value.  Too bad something like
PrvPtrCheck() isn't exposed to the general public.  Anyways, I appreciate
the feedback.  I guess I'll just have to find something else to much with.
:)

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
[EMAIL PROTECTED]
Sent: Wednesday, January 24, 2001 6:18 PM
To: Palm Developer Forum
Subject: RE: How to test for valid pointers?





I would like to elaborate on what Danny just posted:

> You are expected to keep track of the chunks of
> memory that you allocate so that you don't have dangling pointers or
leaked
> chunks.

Bobby is correct: there is no MemIsValidPtr() function.  If you want to know
if
a pointer is valid, you need to first keep track of all of your calls to
MemPtrNew, MemHandleNew, et al, and enter the results into a list (and
remove
them on the corresponding Free calls). Later, to check for validity, walk
that
list, seeing if your test 32-bit value is on the list.

Bonus: if you have such a list, you can also use it for memory leak
detection.

-- Keith Rollin
-- Palm OS Emulator engineer






"Bobby Williams" <[EMAIL PROTECTED]> on 01/24/2001 02:28:03 PM

Please respond to "Palm Developer Forum" <[EMAIL PROTECTED]>

Sent by:  "Bobby Williams" <[EMAIL PROTECTED]>


To:   "Palm Developer Forum" <[EMAIL PROTECTED]>
cc:    (Keith Rollin/US/PALM)
Subject:  RE: How to test for valid pointers?



Wow, tough crowd!  Not to be defensive, but I don't think my question was
silly at all.  Perhaps the wording could of been improved, but it's a valid,
non-trivial request for information.  Isn't this one of the purposes of this
list?  There is no MemIsValidPtr()-type of function, and would rather not
make assumptions based upon a given value.  That  is, I would like to be
able to test a given address for validity before riding off the deep end.
People tend not to like applications that causes your device to reset.
Given the level of expertise on this list, I was hoping that there was
someone who has already faces this particual problem.  Obviously, testing
for NULL is not adequate.

BTW, thanks to those who did respond.



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


-- 
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