www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - Pointer validation

↑ ↓ ← 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
↑ ↓ 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
↑ ↓ 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
↑ ↓ → 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