Provides a pool of buffers you can use whenever you need a quick buffer. More...
#include "qev.h"Go to the source code of this file.
Macros | |
| #define | g_string_printf qev_buffer_printf |
| You have no choice: g_string_*printf() is not zero-alloc, and the ones here are. More... | |
| #define | g_string_vprintf qev_buffer_vprintf |
| g_string_vprintf is being hijacked | |
| #define | g_string_append_printf qev_buffer_append_printf |
| g_string_append_printf is being hijacked | |
| #define | g_string_append_vprintf qev_buffer_append_vprintf |
| g_string_append_vprintf is being hijacked | |
| #define | g_string_append(buff, str) qev_buffer_append_len(buff, str, strlen(str)) |
Takes the length of str at compile-time, if possible. More... | |
Functions | |
| GString * | qev_buffer_get () |
| Gets a buffer from the pool. More... | |
| void | qev_buffer_put (GString *buff) |
| Releases a buffer to the pool. More... | |
| void | qev_buffer_put0 (GString **buff) |
| Releases the buffer and sets the pointer to NULL. More... | |
| void | qev_buffer_printf (GString *buff, const gchar *format,...) G_GNUC_PRINTF(2 |
| The variable argument version of qev_buffer_vprintf() More... | |
| void void | qev_buffer_vprintf (GString *buff, const gchar *format, va_list args) G_GNUC_PRINTF(2 |
| glib's g_string_printf() functions are, stupidly enough, NOT zero-allocation (at least as much as appending to a growing buffer can be zero-allocation). More... | |
| void void void | qev_buffer_append_printf (GString *buff, const gchar *format,...) G_GNUC_PRINTF(2 |
| The variable argument version of qev_buffer_append_vprintf() More... | |
| void void void void | qev_buffer_append_vprintf (GString *buff, const gchar *format, va_list args) G_GNUC_PRINTF(2 |
| glib's g_string_append_printf() functions are, stupidly enough, NOT zero-allocation (at least as much as appending to a growing buffer can be zero-allocation). More... | |
| void void void void void | qev_buffer_ensure (GString *buff, const gsize len) |
Ensures that the string will fit at least len bytes more. More... | |
| void | qev_buffer_append_buff (GString *buff, const GString *other) |
| Append a buffer to this buffer. More... | |
| void | qev_buffer_append_len (GString *buff, const gchar *str, const gsize len) |
| A faster alternative to g_string_append_len() More... | |
| void | qev_buffer_clear (GString *buff) |
| A faster alternative to g_string_truncate(str, 0) More... | |
| void | qev_buffer_append_uint (GString *buff, guint64 v) |
| A faster alternative to g_string_printf("%lu", v). More... | |
| void | qev_buffer_replace_str (GString *buff, const gchar *from, const gchar *to) |
| Replace the given sequence in the string with the other. More... | |
Provides a pool of buffers you can use whenever you need a quick buffer.
| #define g_string_append | ( | buff, | |
| str | |||
| ) | qev_buffer_append_len(buff, str, strlen(str)) |
Takes the length of str at compile-time, if possible.
It's a minor but easy optimization.
| #define g_string_printf qev_buffer_printf |
You have no choice: g_string_*printf() is not zero-alloc, and the ones here are.
Their functions are being wholesale replaced to use the non-zero-alloc functions provided here.
| void qev_buffer_append_buff | ( | GString * | buff, |
| const GString * | other | ||
| ) |
Append a buffer to this buffer.
buff and other MAY NOT be the same string.| buff | The buffer to add to |
| other | The buffer to copy from. |
| void qev_buffer_append_len | ( | GString * | buff, |
| const gchar * | str, | ||
| const gsize | len | ||
| ) |
A faster alternative to g_string_append_len()
str to overlap with buff->str in any way. This function is only intended to add other strings to this one.| buff | The buffer to append to |
| str | The string to append |
| len | The length of str |
| void void void qev_buffer_append_printf | ( | GString * | buff, |
| const gchar * | format, | ||
| ... | |||
| ) |
The variable argument version of qev_buffer_append_vprintf()
| buff | The buffer to append to |
| format | The format |
| ... | The arguments to format |
| void qev_buffer_append_uint | ( | GString * | buff, |
| guint64 | v | ||
| ) |
A faster alternative to g_string_printf("%lu", v).
| buff | The string to append to. |
| v | The value to append. |
| void void void void qev_buffer_append_vprintf | ( | GString * | buff, |
| const gchar * | format, | ||
| va_list | args | ||
| ) |
glib's g_string_append_printf() functions are, stupidly enough, NOT zero-allocation (at least as much as appending to a growing buffer can be zero-allocation).
So let's just do it the right way here.
| buff | The buffer to append to |
| format | The format |
| args | The arguments to format |
| void qev_buffer_clear | ( | GString * | buff | ) |
A faster alternative to g_string_truncate(str, 0)
| buff | The buffer to clear |
| void void void void void qev_buffer_ensure | ( | GString * | buff, |
| const gsize | len | ||
| ) |
Ensures that the string will fit at least len bytes more.
That is, ensures that the size of buff->str >= (buff->len + len + 1).
| buff | The buffer to resize |
| len | How much free space to ensure is at the end of the string. In other words, (buff->allocated_len - buff->len) > len. |
| GString* qev_buffer_get | ( | ) |
Gets a buffer from the pool.
| void qev_buffer_printf | ( | GString * | buff, |
| const gchar * | format, | ||
| ... | |||
| ) |
The variable argument version of qev_buffer_vprintf()
| buff | The buffer to print into |
| format | The format |
| ... | The arguments to format |
| void qev_buffer_put | ( | GString * | buff | ) |
Releases a buffer to the pool.
| void qev_buffer_put0 | ( | GString ** | buff | ) |
Releases the buffer and sets the pointer to NULL.
| void qev_buffer_replace_str | ( | GString * | buff, |
| const gchar * | from, | ||
| const gchar * | to | ||
| ) |
Replace the given sequence in the string with the other.
| buff | The buffer to replace in |
| from | The string to search for |
| to | The string to replace with |
| void void qev_buffer_vprintf | ( | GString * | buff, |
| const gchar * | format, | ||
| va_list | args | ||
| ) |
glib's g_string_printf() functions are, stupidly enough, NOT zero-allocation (at least as much as appending to a growing buffer can be zero-allocation).
So let's just do it the right way here.
| buff | The buffer to print into |
| format | The format |
| args | The arguments to format |
1.8.6