RESERVE a Random Seat

From: Bulgrien, Dennis <Dennis.Bulgrien_at_TripointGlobal.com>
Date: Tue, 15 Jan 2002 08:51:33 -0600

Point of legality. According to the documentation, RESERVE (and BUFFER: )
should not be used to allocate sequencial buffers in uData. You may have
missed it since the definition of RESERVE does not state this important
fact; it must be read from general discussion preceding it. I'll give two
examples of code, one unwise; they reserve space in uData and into cData put
a pointer to the space, the number of elements, and initialized data 0 to
n-1.

SwiftX.pdf:
4. Cross-compiler Principles
4.4 DEFINING WORDS
...
Space allocated by a single BUFFER: definition or by a single call to
RESERVE
is guaranteed to be contiguous, but there is no guarantee that space
allocated
by successive uses of these words will be contiguous with earlier
allocations.
...
RESERVE ( n - addr ) Allocate n bytes of uData, starting at addr.

__unwise__

\ CDATA PROG 0000 | IDATA IRAM 1000 | UDATA URAM 2000 |

: (DATABASE) ( -- )
  #ECOUNT 0 DO
    CDATA I ,
    UDATA #ECOUNT #ESIZE * RESERVE
  LOOP
;

CREATE DATABASE UDATA HERE CDATA , #ECOUNT , (DATABASE)

___wise___

: (DATABASE) ( -- )
  CDATA #ECOUNT 0 DO I , LOOP
  UDATA #ECOUNT #ESIZE * RESERVE
;

CREATE DATABASE UDATA HERE CDATA , #ECOUNT , (DATABASE)
----------------------------------------------------------------------
swiftx_at_forth.com The SwiftX programming discussion email list
To unsubscribe, send subject "unsubscribe swiftx" to listar_at_forth.com
For help with listar commands, send subject "help" to listar_at_forth.com
Archives are located at http://www.forth.com/swiftx -- check them out!
----------------------------------------------------------------------
THIS LIST IS NOT FOR BUG REPORTS! Send bug reports to support_at_forth.com.
Received on Tue Jan 15 2002 - 06:53:36 PST


Subscribe to our e-mail list service. It's free for all SwiftForth and SwiftX users!

This archive was generated 09-Feb-2012. Archive updated nightly.