code: func (st *Stack) ensureCapacity(newCapacity uint64) error {
  	// Maximum length of a slice that allocates memory is the same as the native int max size
  	// We could rethink this limit, but we don't want different validators to disagree on
  	// transaction validity so we pick the lowest common denominator
  	if newCapacity > math.MaxInt32 {
  		// If we ever did want more than an int32 of space then we would need to
  		// maintain multiple pages of memory
  		return fmt.Errorf("cannot address memory beyond a maximum index "+
  			"with int32 width (%v bytes)", math.MaxInt32)
  	}
  	newCapacityInt := int(newCapacity)
  	// We're already big enough so return
  	if newCapacityInt <= len(st.slice) {
  		return nil
  	}
  	if st.maxCapacity > 0 && newCapacity > st.maxCapacity {
  		return fmt.Errorf("cannot grow memory because it would exceed the "+
  			"current maximum limit of %v bytes", st.maxCapacity)
  	}
  	// Ensure the backing array of slice is big enough
  	// Grow the memory one word at time using the pre-allocated zeroWords to avoid
  	// unnecessary allocations. Use append to make use of any spare capacity in
  	// the slice's backing array.
  	for newCapacityInt > cap(st.slice) {
  		// We'll trust Go exponentially grow our arrays (at first).
  		st.slice = append(st.slice, Zero256)
  	}
  	// Now we've ensured the backing array of the slice is big enough we can
  	// just re-slice (even if len(mem.slice) < newCapacity)
  	st.slice = st.slice[:newCapacity]
  	return nil
  }
docs: // Ensures the current stack can hold a new element. Will only grow the
  // backing array (will not shrink).