www.digitalmars.com         C & C++   DMDScript  

c++ - Pointer validation

reply Mark Evans <mevans zyvex.com> writes:
Under 16-bit large model, what function can I use to determine whether a given
pointer is actually a valid heap pointer, either _far or _huge.  The memory
management runtimes should be able 
to tell me this information.  I looked in the documentation (web and PDF) but
did not find anything.

Mark
Jun 04 2001
parent reply Jan Knepper <jan smartsoft.cc> writes:
Mark,

Which 16 bits platform are you working on?
I suppose Win16?
Win16 should have:
IsBadCodePtr
IsBadHugeReadPtr
IsBadHugeWritePtr
IsBadReadPtr
IsBadStringPtr
IsBadWritePtr

HTH

Jan



Mark Evans wrote:

 Under 16-bit large model, what function can I use to determine whether a given
pointer is actually a valid heap pointer, either _far or _huge.  The memory
management runtimes should be able
 to tell me this information.  I looked in the documentation (web and PDF) but
did not find anything.

 Mark

Jun 04 2001
parent reply Mark Evans <mevans zyvex.com> writes:
Yes Win16.

When the functions are listed without parameters they look useful.  This
appearance is deceiving.  One of the required 
parameters is the size of the allocation block.  Even a good pointer is then
reported as "bad" if the size with which it was 
allocated does not match the parameter to the function.

So these functions strike me as defeating their own purpose.  If I knew the
block size then I would already know it was a good 
pointer.

What I want is a function that will recognize *any* previously allocated __far
or __huge pointer, of any size, without my having to 
track the size.  Does DM have such a function in its runtimes?

Mark


On Mon, 04 Jun 2001 11:47:47 -0400, Jan Knepper <jan smartsoft.cc> wrote:
 Mark,
 
 Which 16 bits platform are you working on?
 I suppose Win16?
 Win16 should have:
 IsBadCodePtr
 IsBadHugeReadPtr
 IsBadHugeWritePtr
 IsBadReadPtr
 IsBadStringPtr
 IsBadWritePtr
 
 HTH
 
 Jan
 
 
 
 Mark Evans wrote:
 
 Under 16-bit large model, what function can I use to determine whether a given
pointer is actually a valid heap pointer, either 


 to tell me this information.  I looked in the documentation (web and PDF) but
did not find anything.

 Mark


Jun 04 2001
parent Jan Knepper <jan smartsoft.cc> writes:
Mark Evans wrote:

 Yes Win16.

Copied the reply to c++.windows.16-bits
 When the functions are listed without parameters they look useful.  This
appearance is deceiving.  One of the required
 parameters is the size of the allocation block.  Even a good pointer is then
reported as "bad" if the size with which it was
 allocated does not match the parameter to the function.

Well... I figured that you had a helpfile or something where you could look them up and see how they can or can-not help you.
 So these functions strike me as defeating their own purpose.  If I knew the
block size then I would already know it was a good
 pointer.

 What I want is a function that will recognize *any* previously allocated __far
or __huge pointer, of any size, without my having to
 track the size.  Does DM have such a function in its runtimes?

Check into _msize. That might help you a little. Jan
Jun 04 2001