www.delorie.com/gnu/docs/gforth/gforth_83.html   search  
Buy GNU books!

Gforth Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.7.2 Dictionary allocation

Dictionary allocation is a stack-oriented allocation scheme, i.e., if you want to deallocate X, you also deallocate everything allocated after X.

The allocations using the words below are contiguous and grow the region towards increasing addresses. Other words that allocate dictionary memory of any kind (i.e., defining words including :noname) end the contiguous region and start a new one.

In ANS Forth only created words are guaranteed to produce an address that is the start of the following contiguous region. In particular, the cell allocated by variable is not guaranteed to be contiguous with following alloted memory.

You can deallocate memory by using allot with a negative argument (with some restrictions, see allot). For larger deallocations use marker.

doc-here doc-unused doc-allot doc-c, doc-f, doc-, doc-2,

Memory accesses have to be aligned (see section 5.7.5 Address arithmetic). So of course you should allocate memory in an aligned way, too. I.e., before allocating allocating a cell, here must be cell-aligned, etc. The words below align here if it is not already. Basically it is only already aligned for a type, if the last allocation was a multiple of the size of this type and if here was aligned for this type before.

After freshly createing a word, here is aligned in ANS Forth (maxaligned in Gforth).

doc-align doc-falign doc-sfalign doc-dfalign doc-maxalign doc-cfalign

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003