Logo Search packages:      
Sourcecode: tardy version File versions  Download package

void tar_input_filter_gunzip::buffered_unread ( const void *  data,
size_t  len 
) [private]

The buffered_unread method is used to "push back" data into the sources, as seen from the buffered_read method.

Definition at line 98 of file gunzip.cc.

References buffered_data, buffered_data_pos, buffered_data_size, buffered_data_size_max, and deflated_file_pos.

Referenced by read_data().

{
    deflated_file_pos -= len;

    /*
     * If we need a bigger buffer, allocate it from the heap
     * and copy the new and old data into it.
     */
    size_t buffered_nbytes = buffered_data_size - buffered_data_pos;
    if (len + buffered_nbytes > buffered_data_size_max)
    {
      int nbytes = len + buffered_nbytes;
      unsigned char *new_buffered_data = new unsigned char[nbytes];
      memcpy(new_buffered_data, data, len);
      memcpy
      (
          new_buffered_data + len,
          buffered_data + buffered_data_pos,
          buffered_nbytes
      );
      delete buffered_data;
      buffered_data = new_buffered_data;
      new_buffered_data = 0;
      buffered_data_pos = 0;
      buffered_data_size = nbytes;
      buffered_data_size_max = nbytes;
      return;
    }

    /*
     * See if we need to stuffle the data up to make it fit into the
     * existing buffer.
     */
    if (len > buffered_data_pos)
    {
      memmove
      (
          buffered_data + buffered_data_pos,
          buffered_data + buffered_data_size_max - buffered_nbytes,
          buffered_nbytes
      );
      buffered_data_size = buffered_data_size_max;
      buffered_data_pos = buffered_data_size_max - buffered_nbytes;
    }

    /*
     * Add the data onto the *front* of the buffer.
     */
    memcpy(buffered_data + buffered_data_pos - len, data, len);
    buffered_data_pos -= len;
}


Generated by  Doxygen 1.6.0   Back to index