mirror of
https://github.com/pkgconf/pkgconf.git
synced 2026-01-27 01:44:34 +00:00
libpkgconf: buffer: add pkgconf_buffer_append_vfmt
Signed-off-by: Ariadne Conill <ariadne@ariadne.space>
This commit is contained in:
parent
cf246dba4f
commit
def161ad50
@ -66,19 +66,19 @@ pkgconf_buffer_append(pkgconf_buffer_t *buffer, const char *text)
|
||||
}
|
||||
|
||||
void
|
||||
pkgconf_buffer_append_fmt(pkgconf_buffer_t *buffer, const char *fmt, ...)
|
||||
pkgconf_buffer_append_vfmt(pkgconf_buffer_t *buffer, const char *fmt, va_list src_va)
|
||||
{
|
||||
va_list va;
|
||||
char *buf;
|
||||
size_t needed;
|
||||
|
||||
va_start(va, fmt);
|
||||
va_copy(va, src_va);
|
||||
needed = vsnprintf(NULL, 0, fmt, va) + 1;
|
||||
va_end(va);
|
||||
|
||||
buf = malloc(needed);
|
||||
|
||||
va_start(va, fmt);
|
||||
va_copy(va, src_va);
|
||||
vsnprintf(buf, needed, fmt, va);
|
||||
va_end(va);
|
||||
|
||||
@ -87,6 +87,16 @@ pkgconf_buffer_append_fmt(pkgconf_buffer_t *buffer, const char *fmt, ...)
|
||||
free(buf);
|
||||
}
|
||||
|
||||
void
|
||||
pkgconf_buffer_append_fmt(pkgconf_buffer_t *buffer, const char *fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
|
||||
va_start(va, fmt);
|
||||
pkgconf_buffer_append_vfmt(buffer, fmt, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
void
|
||||
pkgconf_buffer_push_byte(pkgconf_buffer_t *buffer, char byte)
|
||||
{
|
||||
|
||||
@ -441,6 +441,7 @@ PKGCONF_API void pkgconf_path_prepend_list(pkgconf_list_t *dst, const pkgconf_li
|
||||
/* buffer.c */
|
||||
PKGCONF_API void pkgconf_buffer_append(pkgconf_buffer_t *buffer, const char *text);
|
||||
PKGCONF_API void pkgconf_buffer_append_fmt(pkgconf_buffer_t *buffer, const char *fmt, ...) PRINTFLIKE(2, 3);
|
||||
PKGCONF_API void pkgconf_buffer_append_vfmt(pkgconf_buffer_t *buffer, const char *fmt, va_list va);
|
||||
PKGCONF_API void pkgconf_buffer_push_byte(pkgconf_buffer_t *buffer, char byte);
|
||||
PKGCONF_API void pkgconf_buffer_trim_byte(pkgconf_buffer_t *buffer);
|
||||
PKGCONF_API void pkgconf_buffer_finalize(pkgconf_buffer_t *buffer);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user