× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



>I'm not really sure what loads
>bufferdtafld.  I got this code from an example
>and modified to output to a file.  I really have
>not used pointers in the past, and while
>understand the underlying principal, it is still a
>little fuzzy.  Here is all the code:
>
> D BufferHdl       S             10I 0
> D BufferSize      S             10I 0 Inz( 1920 )
> D BufferIncr      S             10I 0 Inz( 1920 )
> D NbrBytesRead    S             10I 0
> D BufferPtr       S               *
> D BufferDtaFld    S          32767    Based( BufferPtr )
> D BufferDta       S          32767
> D BufferPos       S             10I 0 Inz( 1 )
> D NoAPIError      C                   Const( *Zero )
> D APIErrorPassed  S              1N
> D Status          S              1N
> D APIErrorDS      DS
> D  BytesProvided                10I 0 Inz( %Size( APIErrorDS ) )
> D  BytesAvail                   10I 0 Inz( *Zero )
> D  MsgID                         7    Inz( *Blanks )
> D  Reserved                      1    Inz( X'00' )
> D  MsgDta                      256    Inz( *Blanks )
>  *
 - snip -
>  *  - Retrieve pointer to buffer data
> C                   Reset                   APIErrorDS
> C                   Eval      BufferPtr = RtvBufferPtr(
> C                                                       BufferHdl  :
> C                                                       *Omit      :
> C                                                       APIErrorDS
> C                                                     )

Here's where BufferDtaFld gets "loaded."  BufferPtr gets set to some area of
memory by the procedure RtvBufferPtr.  When you look at RtvBufferPtr, what
size variable is being pointed to?  There's a "RETURN pointer" in there, and
"pointer" is the address of some variable.  If that variable isn't the same
size as BufferDtaFld, then that's a potential for errors.

Imagine the situation where RtvBufferPtr is pointing to a 1920 byte area of
memory.  Let's say the address is 1 just for the sake of illustration.
Let's name that variable InpBuffer - it's 1920 bytes long, so it occupies
bytes 1 through 1920 in memory.  After the "eval BufferPtr = RtvBufferPtr()"
the value of BufferPtr becomes 1 because RtvBufferPtr passes out the address
of InpBuffer.  Because BufferDtaFld is based on BufferPtr, BufferDtaFld now
occupies bytes 1 through 32767 in memory.

That's where a problem can come in.  RtvBufferPtr only set aside 1920 bytes,
but we're referring to 32k bytes!  The memory beyond 1920 can be holding
other stuff; stuff that shouldn't be changed by say, "eval BufferDtaFld =
''"
  --buck


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.