/* Returns: a #gsize of the number of bytes peeked, or -1 on error.  */
gsize g_buffered_input_stream_peek(GBufferedInputStream *stream, void *buffer, gsize offset, gsize count)
/* Returns: a #gsize of the number of bytes peeked, or -1 on error.  */
gsize g_buffered_input_stream_peek(GBufferedInputStream *stream, void *buffer, gsize offset, gsize count)
{
  gsize available;
  gsize end;
  g_return_val_if_fail (G_IS_BUFFERED_INPUT_STREAM (stream), -1);
  g_return_val_if_fail (buffer != NULL, -1);
  available = g_buffered_input_stream_get_available (stream);
  if (offset > available)
    return 0;
  end = MIN (offset + count, available);
  count = end - offset;
  memcpy (buffer, stream->priv->buffer + stream->priv->pos + offset, count);
  return count;
}