buffer header¶
The documentation of QEMU’s qemu/buffer.h
header.
-
void
buffer_init
(Buffer * buffer, const char * name, ...)¶
Parameters
Buffer * buffer
- the buffer object
const char * name
- buffer name
...
- variable arguments
Description
Optionally attach a name to the buffer, to make it easier to identify in debug traces.
-
void
buffer_shrink
(Buffer * buffer)¶
Parameters
Buffer * buffer
- the buffer object
Description
Try to shrink the buffer. Checks current buffer capacity and size and reduces capacity in case only a fraction of the buffer is actually used.
-
void
buffer_reserve
(Buffer * buffer, size_t len)¶
Parameters
Buffer * buffer
- the buffer object
size_t len
- the minimum required free space
Description
Ensure that the buffer has space allocated for at least len bytes. If the current buffer is too small, it will be reallocated, possibly to a larger size than requested.
-
void
buffer_reset
(Buffer * buffer)¶
Parameters
Buffer * buffer
- the buffer object
Description
Reset the length of the stored data to zero, but do not free / reallocate the memory buffer
-
void
buffer_free
(Buffer * buffer)¶
Parameters
Buffer * buffer
- the buffer object
Description
Reset the length of the stored data to zero and also free the internal memory buffer
-
void
buffer_append
(Buffer * buffer, const void * data, size_t len)¶
Parameters
Buffer * buffer
- the buffer object
const void * data
- the data block to append
size_t len
- the length of data in bytes
Description
Append the contents of data to the end of the buffer. The caller must ensure that the buffer has sufficient free space for len bytes, typically by calling the buffer_reserve() method prior to appending.
-
void
buffer_advance
(Buffer * buffer, size_t len)¶
Parameters
Buffer * buffer
- the buffer object
size_t len
- the number of bytes to skip
Description
Remove len bytes of data from the head of the buffer. The internal buffer will not be reallocated, so will have at least len bytes of free space after this call completes
-
uint8_t *
buffer_end
(Buffer * buffer)¶
Parameters
Buffer * buffer
- the buffer object
Description
Get a pointer to the tail end of the internal buffer The returned pointer is only valid until the next call to buffer_reserve().
Return
the tail of the buffer
-
gboolean
buffer_empty
(Buffer * buffer)¶
Parameters
Buffer * buffer
- the buffer object
Description
Determine if the buffer contains any current data
Return
true if the buffer holds data, false otherwise
-
void
buffer_move_empty
(Buffer * to, Buffer * from)¶
Parameters
Buffer * to
- destination buffer object
Buffer * from
- source buffer object
Description
Moves buffer, without copying data. ‘to’ buffer must be empty. ‘from’ buffer is empty and zero-sized on return.
-
void
buffer_move
(Buffer * to, Buffer * from)¶
Parameters
Buffer * to
- destination buffer object
Buffer * from
- source buffer object
Description
Moves buffer, copying data (unless ‘to’ buffer happens to be empty). ‘from’ buffer is empty and zero-sized on return.