Lines Matching full:buffer

2  * buffer.c
24 * libpkgconf `buffer` module
27 * The libpkgconf `buffer` module contains the functions related to managing
39 buffer_debug(pkgconf_buffer_t *buffer)
41 for (char *c = buffer->base; c <= buffer->end; c++)
53 * .. c:function:: bool pkgconf_buffer_append(pkgconf_buffer_t *buffer, const char *text)
55 * Append a null-terminated string to the buffer, reallocating as necessary.
57 * :param pkgconf_buffer_t *buffer: The buffer to append to.
62 pkgconf_buffer_append(pkgconf_buffer_t *buffer, const char *text) in pkgconf_buffer_append() argument
65 size_t newsize = pkgconf_buffer_len(buffer) + needed; in pkgconf_buffer_append()
67 char *newbase = realloc(buffer->base, target_allocation_size(newsize)); in pkgconf_buffer_append()
71 char *newend = newbase + pkgconf_buffer_len(buffer); in pkgconf_buffer_append()
74 buffer->base = newbase; in pkgconf_buffer_append()
75 buffer->end = newend + (needed - 1); in pkgconf_buffer_append()
77 *buffer->end = '\0'; in pkgconf_buffer_append()
86 * Append a slice of *n* bytes to the buffer. Does nothing if *n* is zero.
88 * :param pkgconf_buffer_t *buf: The buffer to append to.
111 …* .. c:function:: bool pkgconf_buffer_append_vfmt(pkgconf_buffer_t *buffer, const char *fmt, va_li…
113 * Append a formatted string to the buffer using a :code:`va_list`.
115 * :param pkgconf_buffer_t *buffer: The buffer to append to.
121 pkgconf_buffer_append_vfmt(pkgconf_buffer_t *buffer, const char *fmt, va_list src_va) in pkgconf_buffer_append_vfmt() argument
139 bool ret = pkgconf_buffer_append(buffer, buf); in pkgconf_buffer_append_vfmt()
149 * .. c:function:: bool pkgconf_buffer_append_fmt(pkgconf_buffer_t *buffer, const char *fmt, ...)
151 * Append a formatted string to the buffer using variadic arguments.
153 * :param pkgconf_buffer_t *buffer: The buffer to append to.
158 pkgconf_buffer_append_fmt(pkgconf_buffer_t *buffer, const char *fmt, ...) in pkgconf_buffer_append_fmt() argument
163 bool ret = pkgconf_buffer_append_vfmt(buffer, fmt, va); in pkgconf_buffer_append_fmt()
172 * .. c:function:: bool pkgconf_buffer_prepend(pkgconf_buffer_t *buffer, const char *text)
174 * Prepend a null-terminated string to the beginning of the buffer.
175 * If *text* is NULL, the buffer contents are unchanged.
177 * :param pkgconf_buffer_t *buffer: The buffer to prepend to.
182 pkgconf_buffer_prepend(pkgconf_buffer_t *buffer, const char *text) in pkgconf_buffer_prepend() argument
189 if (!pkgconf_buffer_append(&tmpbuf, pkgconf_buffer_str_or_empty(buffer))) in pkgconf_buffer_prepend()
196 pkgconf_buffer_copy(&tmpbuf, buffer); in pkgconf_buffer_prepend()
206 * .. c:function:: bool pkgconf_buffer_push_byte(pkgconf_buffer_t *buffer, char byte)
208 * Append a single byte to the buffer, reallocating as necessary.
210 * :param pkgconf_buffer_t *buffer: The buffer to append to.
215 pkgconf_buffer_push_byte(pkgconf_buffer_t *buffer, char byte) in pkgconf_buffer_push_byte() argument
217 size_t newsize = pkgconf_buffer_len(buffer) + 1; in pkgconf_buffer_push_byte()
218 char *newbase = realloc(buffer->base, target_allocation_size(newsize)); in pkgconf_buffer_push_byte()
226 buffer->base = newbase; in pkgconf_buffer_push_byte()
227 buffer->end = newend; in pkgconf_buffer_push_byte()
235 * .. c:function:: bool pkgconf_buffer_trim_byte(pkgconf_buffer_t *buffer)
237 * Remove the last byte from the buffer. The buffer must be non-empty.
239 * :param pkgconf_buffer_t *buffer: The buffer to trim.
243 pkgconf_buffer_trim_byte(pkgconf_buffer_t *buffer) in pkgconf_buffer_trim_byte() argument
245 size_t len = pkgconf_buffer_len(buffer); in pkgconf_buffer_trim_byte()
250 char *newbase = realloc(buffer->base, target_allocation_size(newsize)); in pkgconf_buffer_trim_byte()
255 buffer->base = newbase; in pkgconf_buffer_trim_byte()
256 buffer->end = newbase + newsize; in pkgconf_buffer_trim_byte()
257 *(buffer->end) = '\0'; in pkgconf_buffer_trim_byte()
265 * .. c:function:: void pkgconf_buffer_finalize(pkgconf_buffer_t *buffer)
267 * Free all memory owned by the buffer and reset it to an empty state.
269 * :param pkgconf_buffer_t *buffer: The buffer to finalize.
273 pkgconf_buffer_finalize(pkgconf_buffer_t *buffer) in pkgconf_buffer_finalize() argument
275 free(buffer->base); in pkgconf_buffer_finalize()
276 buffer->base = buffer->end = NULL; in pkgconf_buffer_finalize()
282 * .. c:function:: bool pkgconf_buffer_fputs(pkgconf_buffer_t *buffer, FILE *out)
284 * Write the buffer contents followed by a newline to a file stream.
285 * If the buffer is empty, only a newline is written.
287 * :param pkgconf_buffer_t *buffer: The buffer to write.
293 pkgconf_buffer_fputs(pkgconf_buffer_t *buffer, FILE *out) in pkgconf_buffer_fputs() argument
295 if (pkgconf_buffer_len(buffer) != 0) in pkgconf_buffer_fputs()
297 if (fputs(pkgconf_buffer_str(buffer), out) == EOF) in pkgconf_buffer_fputs()
310 * .. c:function:: bool pkgconf_buffer_vjoin(pkgconf_buffer_t *buffer, char delim, va_list src_va)
312 * Join a NULL-terminated list of strings into the buffer, separated by *delim*.
315 * :param pkgconf_buffer_t *buffer: The buffer to join into.
321 pkgconf_buffer_vjoin(pkgconf_buffer_t *buffer, char delim, va_list src_va) in pkgconf_buffer_vjoin() argument
330 if (pkgconf_buffer_str(buffer) != NULL) in pkgconf_buffer_vjoin()
332 if (!pkgconf_buffer_push_byte(buffer, delim)) in pkgconf_buffer_vjoin()
339 if (!pkgconf_buffer_append(buffer, arg)) in pkgconf_buffer_vjoin()
354 * .. c:function:: bool pkgconf_buffer_join(pkgconf_buffer_t *buffer, int delim, ...)
356 * Join a NULL-terminated list of strings into the buffer, separated by *delim*.
359 * :param pkgconf_buffer_t *buffer: The buffer to join into.
364 pkgconf_buffer_join(pkgconf_buffer_t *buffer, int delim, ...) in pkgconf_buffer_join() argument
369 bool ret = pkgconf_buffer_vjoin(buffer, (char)delim, va); in pkgconf_buffer_join()
380 * Test whether the buffer begins with the contents of *prefix*.
382 * :param pkgconf_buffer_t *haystack: The buffer to search in.
400 * Test whether the buffer contains the contents of *needle* as a substring.
402 * :param pkgconf_buffer_t *haystack: The buffer to search in.
420 * Test whether the buffer contains a given byte.
422 * :param pkgconf_buffer_t *haystack: The buffer to search in.
441 * :param pkgconf_buffer_t *haystack: The first buffer.
442 * :param pkgconf_buffer_t *needle: The second buffer.
465 * :param pkgconf_buffer_t *dest: The destination buffer.
466 * :param pkgconf_buffer_t *src: The source buffer.
517 * :param pkgconf_buffer_t *dest: The destination buffer.
518 * :param pkgconf_buffer_t *src: The source buffer.