/* Sets the size of the internal buffer of @stream to @size, or to the size of the contents of the buffer. The buffer can never be resized smaller than its current contents.  */
void g_buffered_input_stream_set_buffer_size(GBufferedInputStream *stream, gsize size)
/* Sets the size of the internal buffer of @stream to @size, or to the size of the contents of the buffer. The buffer can never be resized smaller than its current contents.  */
void g_buffered_input_stream_set_buffer_size(GBufferedInputStream *stream, gsize size)
{
  GBufferedInputStreamPrivate *priv;
  gsize in_buffer;
  guint8 *buffer;
  g_return_if_fail (G_IS_BUFFERED_INPUT_STREAM (stream));
  priv = stream->priv;
  if (priv->len == size)
    return;
  if (priv->buffer)
    {
      in_buffer = priv->end - priv->pos;
      size = MAX (size, in_buffer);
      buffer = g_malloc (size);
      memcpy (buffer, priv->buffer + priv->pos, in_buffer);
      priv->len = size;
      priv->pos = 0;
      priv->end = in_buffer;
      g_free (priv->buffer);
      priv->buffer = buffer;
    }
  else
    {
      priv->len = size;
      priv->pos = 0;
      priv->end = 0;
      priv->buffer = g_malloc (size);
    }
  g_object_notify (G_OBJECT (stream), "buffer-size");
}