diff options
| -rw-r--r-- | buffer.c | 9 | ||||
| -rw-r--r-- | buffer.h | 2 | ||||
| -rw-r--r-- | test/core/buffer-test.c | 8 | ||||
| -rw-r--r-- | vis-registers.c | 3 |
4 files changed, 2 insertions, 20 deletions
@@ -135,15 +135,6 @@ bool buffer_appendf(Buffer *buf, const char *fmt, ...) { return ret; } -bool buffer_printf(Buffer *buf, const char *fmt, ...) { - buf->len = 0; - va_list ap; - va_start(ap, fmt); - bool ret = buffer_vappendf(buf, fmt, ap); - va_end(ap); - return ret; -} - size_t buffer_length0(Buffer *buf) { size_t len = buf->len; if (len > 0 && buf->data[len-1] == '\0') @@ -46,8 +46,6 @@ bool buffer_append0(Buffer*, const char *data); bool buffer_prepend(Buffer*, const void *data, size_t len); /** Insert NUL-terminated data at the start. */ bool buffer_prepend0(Buffer*, const char *data); -/** Set formatted buffer content, ensures NUL termination on success. */ -bool buffer_printf(Buffer*, const char *fmt, ...) __attribute__((format(printf, 2, 3))); /** Append formatted buffer content, ensures NUL termination on success. */ bool buffer_appendf(Buffer*, const char *fmt, ...) __attribute__((format(printf, 2, 3))); /** Return length of a buffer without trailing NUL byte. */ diff --git a/test/core/buffer-test.c b/test/core/buffer-test.c index 269f792..f3b2dad 100644 --- a/test/core/buffer-test.c +++ b/test/core/buffer-test.c @@ -57,14 +57,6 @@ int main(int argc, char *argv[]) { buf.len = 0; skip_if(TIS_INTERPRETER, 1, "vsnprintf not supported") { - - ok(buffer_printf(&buf, "Test: %d\n", 42) && compare0(&buf, "Test: 42\n"), "Set formatted"); - ok(buffer_printf(&buf, "%d\n", 42) && compare0(&buf, "42\n"), "Set formatted overwrite"); - buf.len = 0; - - ok(buffer_printf(&buf, "%s", "") && compare0(&buf, ""), "Set formatted empty string"); - buf.len = 0; - bool append = true; for (int i = 1; i <= 10; i++) append &= buffer_appendf(&buf, "%d", i); diff --git a/vis-registers.c b/vis-registers.c index 03fd728..e1f2c92 100644 --- a/vis-registers.c +++ b/vis-registers.c @@ -54,7 +54,8 @@ const char *register_slot_get(Vis *vis, Register *reg, size_t slot, size_t *len) Buffer *buf = array_get(®->values, 0); if (!buf) return NULL; - buffer_printf(buf, "%zu", slot+1); + buf->len = 0; + buffer_appendf(buf, "%zu", slot+1); if (len) *len = buffer_length0(buf); return buffer_content0(buf); |
