fn heap_allocate(&mut self, n: Word, init_nil: bool)
    -> Result<*mut Word, HeapError>
  {
    let pos = self.htop;
    // Explicitly forbid expanding without a GC, fail if capacity is exceeded
    if pos + n >= self.stop {
      return Err(HeapError::HeapIsFull);
    }

    // Assume we can grow the data without reallocating
    let raw_nil = nil().raw();
    let new_chunk = unsafe {
      self.heap_begin_mut().offset(self.htop as isize)
    };

    if init_nil {
      unsafe {
        for i in 0..n {
          *new_chunk.offset(i as isize) = raw_nil
        }
      }
    }

    self.htop += n;

    Ok(new_chunk)
  }
/// Expand heap to host `n` words of data
Expand heap to host `n` words of data
Expand heap to host ` n ` words of data
fn heap_allocate(&mut self, n: Word, init_nil: bool)
    -> Result<*mut Word, HeapError>
  {
    let pos = self.htop;
    // Explicitly forbid expanding without a GC, fail if capacity is exceeded
    if pos + n >= self.stop {
      return Err(HeapError::HeapIsFull);
    }
    // Assume we can grow the data without reallocating
    let raw_nil = nil().raw();
    let new_chunk = unsafe {
      self.heap_begin_mut().offset(self.htop as isize)
    };
    if init_nil {
      unsafe {
        for i in 0..n {
          *new_chunk.offset(i as isize) = raw_nil
        }
      }
    }
    self.htop += n;
    Ok(new_chunk)
  }
fn heap_allocate ( & mut self , n : Word , init_nil : bool ) -> Result < * mut Word , HeapError > { let pos = self . htop ; // Explicitly forbid expanding without a GC, fail if capacity is exceeded if pos + n >= self . stop { return Err ( HeapError :: HeapIsFull ) ; } // Assume we can grow the data without reallocating let raw_nil = nil ( ) . raw ( ) ; let new_chunk = unsafe { self . heap_begin_mut ( ) . offset ( self . htop as isize ) } ; if init_nil { unsafe { for i in 0 .. n { * new_chunk . offset ( i as isize ) = raw_nil } } } self . htop += n ; Ok ( new_chunk ) }
Expand heap to host `n` words of data
Expand heap to host ` n ` words of data
&mut self
n
Word
init_nil
bool