fn enlarge(&mut self) -> Result<(), AllocError> {
		if self.start == 0 && self.len == self.bufsize {
			/*
			we used to have configurable increments for the bufsize
			now though we double buffer size, just like rust's vec/raw_vec do
			*/
			self.bufsize *= 2;
			let mut new = Buffer::uninitialized(self.bufsize * 2)?;
			// see .new() for th reasons why we read bufsize back
			self.bufsize = new.len() / 2;
			// move data at the start of new buffer
			unsafe {
				core::ptr::copy(
					self.buf.as_mut_slice()[self.start..].as_mut_ptr(),
					new.as_mut_slice().as_mut_ptr(),
					self.len,
				);
			}
			self.start = 0;
			self.buf = new;
		} else {
			// there's plenty of room in the buffer,
			// nothing to do here
		}
		Ok(())
	}
// make room for new data one way or the other
make room for new data one way or the other
make room for new data one way or the other
fn enlarge(&mut self) -> Result<(), AllocError> {
		if self.start == 0 && self.len == self.bufsize {
			/*
			we used to have configurable increments for the bufsize
			now though we double buffer size, just like rust's vec/raw_vec do
			*/
			self.bufsize *= 2;
			let mut new = Buffer::uninitialized(self.bufsize * 2)?;
			// see .new() for th reasons why we read bufsize back
			self.bufsize = new.len() / 2;
			// move data at the start of new buffer
			unsafe {
				core::ptr::copy(
					self.buf.as_mut_slice()[self.start..].as_mut_ptr(),
					new.as_mut_slice().as_mut_ptr(),
					self.len,
				);
			}
			self.start = 0;
			self.buf = new;
		} else {
			// there's plenty of room in the buffer,
			// nothing to do here
		}
		Ok(())
	}
fn enlarge ( & mut self ) -> Result < ( ) , AllocError > { if self . start == 0 && self . len == self . bufsize { /*
			we used to have configurable increments for the bufsize
			now though we double buffer size, just like rust's vec/raw_vec do
			*/ self . bufsize *= 2 ; let mut new = Buffer :: uninitialized ( self . bufsize * 2 ) ? ; // see .new() for th reasons why we read bufsize back self . bufsize = new . len ( ) / 2 ; // move data at the start of new buffer unsafe { core :: ptr :: copy ( self . buf . as_mut_slice ( ) [ self . start .. ] . as_mut_ptr ( ) , new . as_mut_slice ( ) . as_mut_ptr ( ) , self . len , ) ; } self . start = 0 ; self . buf = new ; } else { // there's plenty of room in the buffer, // nothing to do here } Ok ( ( ) ) }
make room for new data one way or the other
make room for new data one way or the other
&mut self
&mut self