/* Sets the size of the internal buffer to @size.  */
void g_buffered_output_stream_set_buffer_size(GBufferedOutputStream *stream, gsize size)
/* Sets the size of the internal buffer to @size.  */
void g_buffered_output_stream_set_buffer_size(GBufferedOutputStream *stream, gsize size)
{
  GBufferedOutputStreamPrivate *priv;
  guint8 *buffer;
  g_return_if_fail (G_IS_BUFFERED_OUTPUT_STREAM (stream));
  priv = stream->priv;
  if (size == priv->len)
    return;
  if (priv->buffer)
    {
      size = MAX (size, priv->pos);
      buffer = g_malloc (size);
      memcpy (buffer, priv->buffer, priv->pos);
      g_free (priv->buffer);
      priv->buffer = buffer;
      priv->len = size;
    }
  else
    {
      priv->buffer = g_malloc (size);
      priv->len = size;
      priv->pos = 0;
    }
  g_object_notify (G_OBJECT (stream), "buffer-size");
}