mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 14:36:13 +01:00
Trivial cleanups
This commit is contained in:
parent
48881bad99
commit
1ba87d1a0e
@ -53,9 +53,7 @@
|
||||
* buffered input stream's buffer, use
|
||||
* g_buffered_input_stream_set_buffer_size(). Note that the buffer's size
|
||||
* cannot be reduced below the size of the data within the buffer.
|
||||
*
|
||||
**/
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#define DEFAULT_BUFFER_SIZE 4096
|
||||
@ -177,12 +175,12 @@ g_buffered_input_stream_class_init (GBufferedInputStreamClass *klass)
|
||||
|
||||
/**
|
||||
* g_buffered_input_stream_get_buffer_size:
|
||||
* @stream: #GBufferedInputStream.
|
||||
* @stream: a #GBufferedInputStream
|
||||
*
|
||||
* Gets the size of the input buffer.
|
||||
*
|
||||
* Returns: the current buffer size.
|
||||
**/
|
||||
*/
|
||||
gsize
|
||||
g_buffered_input_stream_get_buffer_size (GBufferedInputStream *stream)
|
||||
{
|
||||
@ -193,13 +191,13 @@ g_buffered_input_stream_get_buffer_size (GBufferedInputStream *stream)
|
||||
|
||||
/**
|
||||
* g_buffered_input_stream_set_buffer_size:
|
||||
* @stream: #GBufferedInputStream.
|
||||
* @size: a #gsize.
|
||||
* @stream: a #GBufferedInputStream
|
||||
* @size: a #gsize
|
||||
*
|
||||
* 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)
|
||||
@ -261,7 +259,6 @@ g_buffered_input_stream_set_property (GObject *object,
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
@ -313,13 +310,13 @@ g_buffered_input_stream_init (GBufferedInputStream *stream)
|
||||
|
||||
/**
|
||||
* g_buffered_input_stream_new:
|
||||
* @base_stream: a #GInputStream.
|
||||
* @base_stream: a #GInputStream
|
||||
*
|
||||
* Creates a new #GInputStream from the given @base_stream, with
|
||||
* a buffer set to the default size (4 kilobytes).
|
||||
*
|
||||
* Returns: a #GInputStream for the given @base_stream.
|
||||
**/
|
||||
*/
|
||||
GInputStream *
|
||||
g_buffered_input_stream_new (GInputStream *base_stream)
|
||||
{
|
||||
@ -336,14 +333,14 @@ g_buffered_input_stream_new (GInputStream *base_stream)
|
||||
|
||||
/**
|
||||
* g_buffered_input_stream_new_sized:
|
||||
* @base_stream: a #GInputStream.
|
||||
* @size: a #gsize.
|
||||
* @base_stream: a #GInputStream
|
||||
* @size: a #gsize
|
||||
*
|
||||
* Creates a new #GBufferedInputStream from the given @base_stream,
|
||||
* with a buffer set to @size.
|
||||
*
|
||||
* Returns: a #GInputStream.
|
||||
**/
|
||||
*/
|
||||
GInputStream *
|
||||
g_buffered_input_stream_new_sized (GInputStream *base_stream,
|
||||
gsize size)
|
||||
@ -362,10 +359,10 @@ g_buffered_input_stream_new_sized (GInputStream *base_stream,
|
||||
|
||||
/**
|
||||
* g_buffered_input_stream_fill:
|
||||
* @stream: #GBufferedInputStream.
|
||||
* @count: the number of bytes that will be read from the stream.
|
||||
* @cancellable: optional #GCancellable object, %NULL to ignore.
|
||||
* @error: location to store the error occuring, or %NULL to ignore.
|
||||
* @stream: a #GBufferedInputStream
|
||||
* @count: the number of bytes that will be read from the stream
|
||||
* @cancellable: optional #GCancellable object, %NULL to ignore
|
||||
* @error: location to store the error occuring, or %NULL to ignore
|
||||
*
|
||||
* Tries to read @count bytes from the stream into the buffer.
|
||||
* Will block during this read.
|
||||
@ -394,7 +391,7 @@ g_buffered_input_stream_new_sized (GInputStream *base_stream,
|
||||
*
|
||||
* Returns: the number of bytes read into @stream's buffer, up to @count,
|
||||
* or -1 on error.
|
||||
**/
|
||||
*/
|
||||
gssize
|
||||
g_buffered_input_stream_fill (GBufferedInputStream *stream,
|
||||
gssize count,
|
||||
@ -447,13 +444,13 @@ async_fill_callback_wrapper (GObject *source_object,
|
||||
|
||||
/**
|
||||
* g_buffered_input_stream_fill_async:
|
||||
* @stream: #GBufferedInputStream.
|
||||
* @count: the number of bytes that will be read from the stream.
|
||||
* @stream: a #GBufferedInputStream
|
||||
* @count: the number of bytes that will be read from the stream
|
||||
* @io_priority: the <link linkend="io-priority">I/O priority</link>
|
||||
* of the request.
|
||||
* of the request
|
||||
* @cancellable: optional #GCancellable object
|
||||
* @callback: a #GAsyncReadyCallback.
|
||||
* @user_data: a #gpointer.
|
||||
* @callback: a #GAsyncReadyCallback
|
||||
* @user_data: a #gpointer
|
||||
*
|
||||
* Reads data into @stream's buffer asynchronously, up to @count size.
|
||||
* @io_priority can be used to prioritize reads. For the synchronous
|
||||
@ -461,7 +458,7 @@ async_fill_callback_wrapper (GObject *source_object,
|
||||
*
|
||||
* If @count is -1 then the attempted read size is equal to the number
|
||||
* of bytes that are required to fill the buffer.
|
||||
**/
|
||||
*/
|
||||
void
|
||||
g_buffered_input_stream_fill_async (GBufferedInputStream *stream,
|
||||
gssize count,
|
||||
@ -518,14 +515,14 @@ g_buffered_input_stream_fill_async (GBufferedInputStream *stream,
|
||||
|
||||
/**
|
||||
* g_buffered_input_stream_fill_finish:
|
||||
* @stream: a #GBufferedInputStream.
|
||||
* @result: a #GAsyncResult.
|
||||
* @error: a #GError.
|
||||
* @stream: a #GBufferedInputStream
|
||||
* @result: a #GAsyncResult
|
||||
* @error: a #GError
|
||||
*
|
||||
* Finishes an asynchronous read.
|
||||
*
|
||||
* Returns: a #gssize of the read stream, or %-1 on an error.
|
||||
**/
|
||||
*/
|
||||
gssize
|
||||
g_buffered_input_stream_fill_finish (GBufferedInputStream *stream,
|
||||
GAsyncResult *result,
|
||||
@ -554,12 +551,12 @@ g_buffered_input_stream_fill_finish (GBufferedInputStream *stream,
|
||||
|
||||
/**
|
||||
* g_buffered_input_stream_get_available:
|
||||
* @stream: #GBufferedInputStream.
|
||||
* @stream: #GBufferedInputStream
|
||||
*
|
||||
* Gets the size of the available data within the stream.
|
||||
*
|
||||
* Returns: size of the available stream.
|
||||
**/
|
||||
*/
|
||||
gsize
|
||||
g_buffered_input_stream_get_available (GBufferedInputStream *stream)
|
||||
{
|
||||
@ -570,16 +567,16 @@ g_buffered_input_stream_get_available (GBufferedInputStream *stream)
|
||||
|
||||
/**
|
||||
* g_buffered_input_stream_peek:
|
||||
* @stream: a #GBufferedInputStream.
|
||||
* @buffer: a pointer to an allocated chunk of memory.
|
||||
* @offset: a #gsize.
|
||||
* @count: a #gsize.
|
||||
* @stream: a #GBufferedInputStream
|
||||
* @buffer: a pointer to an allocated chunk of memory
|
||||
* @offset: a #gsize
|
||||
* @count: a #gsize
|
||||
*
|
||||
* Peeks in the buffer, copying data of size @count into @buffer,
|
||||
* offset @offset bytes.
|
||||
*
|
||||
* Returns: a #gsize of the number of bytes peeked, or %-1 on error.
|
||||
**/
|
||||
* Returns: a #gsize of the number of bytes peeked, or -1 on error.
|
||||
*/
|
||||
gsize
|
||||
g_buffered_input_stream_peek (GBufferedInputStream *stream,
|
||||
void *buffer,
|
||||
@ -606,15 +603,15 @@ g_buffered_input_stream_peek (GBufferedInputStream *stream,
|
||||
|
||||
/**
|
||||
* g_buffered_input_stream_peek_buffer:
|
||||
* @stream: a #GBufferedInputStream.
|
||||
* @count: a #gsize to get the number of bytes available in the buffer.
|
||||
* @stream: a #GBufferedInputStream
|
||||
* @count: a #gsize to get the number of bytes available in the buffer
|
||||
*
|
||||
* Returns the buffer with the currently available bytes. The returned
|
||||
* buffer must not be modified and will become invalid when reading from
|
||||
* the stream or filling the buffer.
|
||||
*
|
||||
* Returns: read-only buffer
|
||||
**/
|
||||
*/
|
||||
const void*
|
||||
g_buffered_input_stream_peek_buffer (GBufferedInputStream *stream,
|
||||
gsize *count)
|
||||
@ -787,7 +784,9 @@ g_buffered_input_stream_read (GInputStream *stream,
|
||||
return count;
|
||||
}
|
||||
|
||||
/* Full request not available, read all currently availbile and request refill for more */
|
||||
/* Full request not available, read all currently available and
|
||||
* request refill for more
|
||||
*/
|
||||
|
||||
memcpy (buffer, priv->buffer + priv->pos, available);
|
||||
priv->pos = 0;
|
||||
@ -841,9 +840,9 @@ g_buffered_input_stream_read (GInputStream *stream,
|
||||
|
||||
/**
|
||||
* g_buffered_input_stream_read_byte:
|
||||
* @stream: #GBufferedInputStream.
|
||||
* @cancellable: optional #GCancellable object, %NULL to ignore.
|
||||
* @error: location to store the error occuring, or %NULL to ignore.
|
||||
* @stream: a #GBufferedInputStream
|
||||
* @cancellable: optional #GCancellable object, %NULL to ignore
|
||||
* @error: location to store the error occuring, or %NULL to ignore
|
||||
*
|
||||
* Tries to read a single byte from the stream or the buffer. Will block
|
||||
* during this read.
|
||||
@ -860,7 +859,7 @@ g_buffered_input_stream_read (GInputStream *stream,
|
||||
* On error -1 is returned and @error is set accordingly.
|
||||
*
|
||||
* Returns: the byte read from the @stream, or -1 on end of stream or error.
|
||||
**/
|
||||
*/
|
||||
int
|
||||
g_buffered_input_stream_read_byte (GBufferedInputStream *stream,
|
||||
GCancellable *cancellable,
|
||||
@ -956,7 +955,9 @@ fill_async_callback (GObject *source_object,
|
||||
g_object_unref (object);
|
||||
}
|
||||
|
||||
/* Complete immediately, not in idle, since we're already in a mainloop callout */
|
||||
/* Complete immediately, not in idle, since we're already
|
||||
* in a mainloop callout
|
||||
*/
|
||||
g_simple_async_result_complete (simple);
|
||||
g_object_unref (simple);
|
||||
}
|
||||
@ -1017,7 +1018,8 @@ g_buffered_input_stream_real_fill_finish (GBufferedInputStream *stream,
|
||||
return nread;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
gssize bytes_read;
|
||||
gssize count;
|
||||
void *buffer;
|
||||
@ -1056,7 +1058,9 @@ large_read_callback (GObject *source_object,
|
||||
if (error)
|
||||
g_error_free (error);
|
||||
|
||||
/* Complete immediately, not in idle, since we're already in a mainloop callout */
|
||||
/* Complete immediately, not in idle, since we're already
|
||||
* in a mainloop callout
|
||||
*/
|
||||
g_simple_async_result_complete (simple);
|
||||
g_object_unref (simple);
|
||||
}
|
||||
@ -1100,7 +1104,9 @@ read_fill_buffer_callback (GObject *source_object,
|
||||
if (error)
|
||||
g_error_free (error);
|
||||
|
||||
/* Complete immediately, not in idle, since we're already in a mainloop callout */
|
||||
/* Complete immediately, not in idle, since we're already
|
||||
* in a mainloop callout
|
||||
*/
|
||||
g_simple_async_result_complete (simple);
|
||||
g_object_unref (simple);
|
||||
}
|
||||
@ -1147,7 +1153,9 @@ g_buffered_input_stream_read_async (GInputStream *stream,
|
||||
}
|
||||
|
||||
|
||||
/* Full request not available, read all currently availbile and request refill for more */
|
||||
/* Full request not available, read all currently available
|
||||
* and request refill for more
|
||||
*/
|
||||
|
||||
memcpy (buffer, priv->buffer + priv->pos, available);
|
||||
priv->pos = 0;
|
||||
@ -1196,7 +1204,8 @@ g_buffered_input_stream_read_finish (GInputStream *stream,
|
||||
return data->bytes_read;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
gssize bytes_skipped;
|
||||
gssize count;
|
||||
} SkipAsyncData;
|
||||
@ -1234,7 +1243,9 @@ large_skip_callback (GObject *source_object,
|
||||
if (error)
|
||||
g_error_free (error);
|
||||
|
||||
/* Complete immediately, not in idle, since we're already in a mainloop callout */
|
||||
/* Complete immediately, not in idle, since we're already
|
||||
* in a mainloop callout
|
||||
*/
|
||||
g_simple_async_result_complete (simple);
|
||||
g_object_unref (simple);
|
||||
}
|
||||
@ -1264,7 +1275,6 @@ skip_fill_buffer_callback (GObject *source_object,
|
||||
if (nread < 0 && data->bytes_skipped == 0)
|
||||
g_simple_async_result_set_from_error (simple, error);
|
||||
|
||||
|
||||
if (nread > 0)
|
||||
{
|
||||
available = priv->end - priv->pos;
|
||||
@ -1277,7 +1287,9 @@ skip_fill_buffer_callback (GObject *source_object,
|
||||
if (error)
|
||||
g_error_free (error);
|
||||
|
||||
/* Complete immediately, not in idle, since we're already in a mainloop callout */
|
||||
/* Complete immediately, not in idle, since we're already
|
||||
* in a mainloop callout
|
||||
*/
|
||||
g_simple_async_result_complete (simple);
|
||||
g_object_unref (simple);
|
||||
}
|
||||
@ -1320,8 +1332,9 @@ g_buffered_input_stream_skip_async (GInputStream *stream,
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Full request not available, skip all currently availbile and request refill for more */
|
||||
/* Full request not available, skip all currently available
|
||||
* and request refill for more
|
||||
*/
|
||||
|
||||
priv->pos = 0;
|
||||
priv->end = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user