pub fn add_members(&mut self, members: Vec<&str>) -> Result<*mut *mut c_char, NssError> {
        if let Err(ref err) = self.res {
            return Err(err.clone());
        }

        // first check if we have enough space for both the contents of
        // the vector and the C pointer array.
        let amt = members.len();
        let apos = 8 * ((self.bufpos + 7) / 8);
        let sz = (amt + 1) * std::mem::size_of::<*mut c_char>();
        if apos + sz >= self.buflen {
            self.res = Err(NssError::InsufficientBuffer);
            return Err(NssError::InsufficientBuffer);
        }

        // Create the pointer array.
        let (array, array_ptr) = unsafe {
            let buf_cur = self.buffer.offset(apos as isize);
            let buf_cur: *mut *mut c_char = buf_cur as *mut *mut c_char;
            self.bufpos = apos + sz;
            (std::slice::from_raw_parts_mut(buf_cur, amt + 1), buf_cur)
        };

        // Add vector items and set pointers.
        for idx in 0 .. members.len() {
            match self.add_string(&members[idx]) {
                Ok(ptr) => array[idx] = ptr,
                Err(e) => {
                    self.res = Err(e.clone());
                    return Err(e.clone());
                },
            }
        }

        Ok(array_ptr)
    }
/// add an array of strings.
add an array of strings.
add an array of strings .
pub fn add_members(&mut self, members: Vec<&str>) -> Result<*mut *mut c_char, NssError> {
        if let Err(ref err) = self.res {
            return Err(err.clone());
        }
        // first check if we have enough space for both the contents of
        // the vector and the C pointer array.
        let amt = members.len();
        let apos = 8 * ((self.bufpos + 7) / 8);
        let sz = (amt + 1) * std::mem::size_of::<*mut c_char>();
        if apos + sz >= self.buflen {
            self.res = Err(NssError::InsufficientBuffer);
            return Err(NssError::InsufficientBuffer);
        }
        // Create the pointer array.
        let (array, array_ptr) = unsafe {
            let buf_cur = self.buffer.offset(apos as isize);
            let buf_cur: *mut *mut c_char = buf_cur as *mut *mut c_char;
            self.bufpos = apos + sz;
            (std::slice::from_raw_parts_mut(buf_cur, amt + 1), buf_cur)
        };
        // Add vector items and set pointers.
        for idx in 0 .. members.len() {
            match self.add_string(&members[idx]) {
                Ok(ptr) => array[idx] = ptr,
                Err(e) => {
                    self.res = Err(e.clone());
                    return Err(e.clone());
                },
            }
        }
        Ok(array_ptr)
    }
pub fn add_members ( & mut self , members : Vec < & str > ) -> Result < * mut * mut c_char , NssError > { if let Err ( ref err ) = self . res { return Err ( err . clone ( ) ) ; } // first check if we have enough space for both the contents of // the vector and the C pointer array. let amt = members . len ( ) ; let apos = 8 * ( ( self . bufpos + 7 ) / 8 ) ; let sz = ( amt + 1 ) * std :: mem :: size_of :: < * mut c_char > ( ) ; if apos + sz >= self . buflen { self . res = Err ( NssError :: InsufficientBuffer ) ; return Err ( NssError :: InsufficientBuffer ) ; } // Create the pointer array. let ( array , array_ptr ) = unsafe { let buf_cur = self . buffer . offset ( apos as isize ) ; let buf_cur : * mut * mut c_char = buf_cur as * mut * mut c_char ; self . bufpos = apos + sz ; ( std :: slice :: from_raw_parts_mut ( buf_cur , amt + 1 ) , buf_cur ) } ; // Add vector items and set pointers. for idx in 0 .. members . len ( ) { match self . add_string ( & members [ idx ] ) { Ok ( ptr ) => array [ idx ] = ptr , Err ( e ) => { self . res = Err ( e . clone ( ) ) ; return Err ( e . clone ( ) ) ; } , } } Ok ( array_ptr ) }
add an array of strings.
add an array of strings .
&mut self
members
Vec<&str>