/// Grow table by the specified amount of elements.
///
/// Returns the previous size of the table if growth is successful.
///
/// Returns `None` if table can't be grown by the specified amount of
/// elements, or if the `init_value` is the wrong kind of table element.
///
/// # Unsafety
///
/// Resizing the table can reallocate its internal elements buffer. This
/// table's instance's `VMContext` has raw pointers to the elements buffer
/// that are used by Wasm, and they need to be fixed up before we call into
/// Wasm again. Failure to do so will result in use-after-free inside Wasm.
///
/// Generally, prefer using `InstanceHandle::table_grow`, which encapsulates
/// this unsafety.
Grow table by the specified amount of elements.
Returns the previous size of the table if growth is successful.

Returns `None` if table can't be grown by the specified amount of
elements, or if the `init_value` is the wrong kind of table element.
Grow table by the specified amount of elements . Returns the previous size of the table if growth is successful . Returns ` None ` if table can ' t be grown by the specified amount of elements or if the ` init_value ` is the wrong kind of table element .
pub unsafe fn grow(
        &mut self,
        delta: u32,
        init_value: TableElement,
        store: &mut dyn Store,
    ) -> Result<Option<u32>, Error> {
        let old_size = self.size();
        let new_size = match old_size.checked_add(delta) {
            Some(s) => s,
            None => return Ok(None),
        };
        if !store.table_growing(old_size, new_size, self.maximum())? {
            return Ok(None);
        }
        if let Some(max) = self.maximum() {
            if new_size > max {
                store.table_grow_failed(&format_err!("Table maximum size exceeded"));
                return Ok(None);
            }
        }
        debug_assert!(self.type_matches(&init_value));
        // First resize the storage and then fill with the init value
        match self {
            Table::Static { size, data, .. } => {
                debug_assert!(data[*size as usize..new_size as usize]
                    .iter()
                    .all(|x| *x == 0));
                *size = new_size;
            }
            Table::Dynamic { elements, .. } => {
                elements.resize(new_size as usize, 0);
            }
        }
        self.fill(old_size, init_value, delta)
            .expect("table should not be out of bounds");
        Ok(Some(old_size))
    }
pub unsafe fn grow ( & mut self , delta : u32 , init_value : TableElement , store : & mut dyn Store , ) -> Result < Option < u32 > , Error > { let old_size = self . size ( ) ; let new_size = match old_size . checked_add ( delta ) { Some ( s ) => s , None => return Ok ( None ) , } ; if ! store . table_growing ( old_size , new_size , self . maximum ( ) ) ? { return Ok ( None ) ; } if let Some ( max ) = self . maximum ( ) { if new_size > max { store . table_grow_failed ( & format_err ! ( " " ) ) ; return Ok ( None ) ; } } debug_assert ! ( self type_matches ( init_value ) ) ; // First resize the storage and then fill with the init value match self { Table :: Static { size , data , .. } => { debug_assert ! ( data [ size as usize new_size as usize ] iter ( ) all ( x x 0 ) ) ; * size = new_size ; } Table :: Dynamic { elements , .. } => { elements . resize ( new_size as usize , 0 ) ; } } self . fill ( old_size , init_value , delta ) . expect ( " " ) ; Ok ( Some ( old_size ) ) }
Grow table by the specified amount of elements.
Grow table by the specified amount of elements .
&mut self
delta
u32
init_value
TableElement
store
&mut dyn Store
unsafety
Resizing the table can reallocate its internal elements buffer. This
table's instance's `VMContext` has raw pointers to the elements buffer
that are used by Wasm, and they need to be fixed up before we call into
Wasm again. Failure to do so will result in use-after-free inside Wasm.

Generally, prefer using `InstanceHandle::table_grow`, which encapsulates
this unsafety.
Resizing the table can reallocate its internal elements buffer . This table ' s instance ' s ` VMContext ` has raw pointers to the elements buffer that are used by Wasm and they need to be fixed up before we call into Wasm again . Failure to do so will result in use - after - free inside Wasm . Generally prefer using ` InstanceHandle :: table_grow ` which encapsulates this unsafety .