aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buffer.c6
-rw-r--r--buffer.h7
-rw-r--r--sam.c6
-rw-r--r--test/core/buffer-test.c7
-rw-r--r--vis.c8
5 files changed, 6 insertions, 28 deletions
diff --git a/buffer.c b/buffer.c
index eefeaa9..244cba2 100644
--- a/buffer.c
+++ b/buffer.c
@@ -157,12 +157,6 @@ const char *buffer_content0(Buffer *buf) {
return buf->data;
}
-char *buffer_move(Buffer *buf) {
- char *data = buf->data;
- *buf = (Buffer){0};
- return data;
-}
-
ssize_t read_into_buffer(void *context, char *data, size_t len) {
buffer_append(context, data, len);
return len;
diff --git a/buffer.h b/buffer.h
index f099b32..6920468 100644
--- a/buffer.h
+++ b/buffer.h
@@ -57,13 +57,6 @@ size_t buffer_length0(Buffer*);
* Guaranteed to return a NUL terminated string even if buffer is empty.
*/
const char *buffer_content0(Buffer*);
-/**
- * Borrow underlying buffer data.
- * @rst
- * .. warning:: The caller is responsible to ``free(3)`` it.
- * @endrst
- */
-char *buffer_move(Buffer*);
/** ``read(3p)`` like interface for reading into a Buffer (``context``) */
ssize_t read_into_buffer(void *context, char *data, size_t len);
diff --git a/sam.c b/sam.c
index de547d1..f1d57c5 100644
--- a/sam.c
+++ b/sam.c
@@ -597,7 +597,7 @@ static char *parse_until(const char **s, const char *until, const char *escchars
buffer_terminate(&buf);
- return buffer_move(&buf);
+ return buf.data;
}
static char *parse_delimited(const char **s, int type) {
@@ -645,7 +645,7 @@ static char *parse_text(const char **s, Count *count) {
return NULL;
}
- return buffer_move(&buf);
+ return buf.data;
}
static char *parse_shellcmd(Vis *vis, const char **s) {
@@ -683,7 +683,7 @@ static char *parse_cmdname(const char **s) {
buffer_terminate(&buf);
- return buffer_move(&buf);
+ return buf.data;
}
static Regex *parse_regex(Vis *vis, const char **s) {
diff --git a/test/core/buffer-test.c b/test/core/buffer-test.c
index 72aff97..269f792 100644
--- a/test/core/buffer-test.c
+++ b/test/core/buffer-test.c
@@ -54,12 +54,7 @@ int main(int argc, char *argv[]) {
ok(buffer_append(&buf, "\0baz", 4) && compare(&buf, "foo\0bar\0baz", 11), "Append data");
ok(buffer_grow(&buf, cap+1) && compare(&buf, "foo\0bar\0baz", 11) && buf.size >= cap+1, "Grow");
-
- const char *content = buf.data;
- char *data = buffer_move(&buf);
- ok(data == content && buf.len == 0 && buf.size == 0 && buf.data == NULL, "Move");
- ok(buffer_append0(&buf, "foo") && buf.data != data, "Modify after move");
- free(data);
+ buf.len = 0;
skip_if(TIS_INTERPRETER, 1, "vsnprintf not supported") {
diff --git a/vis.c b/vis.c
index 59e16b7..e5b779f 100644
--- a/vis.c
+++ b/vis.c
@@ -1861,12 +1861,8 @@ static int _vis_pipe_collect(Vis *vis, File *file, Filerange *range, const char*
fullscreen);
buffer_terminate(&bufout);
buffer_terminate(&buferr);
- if (out)
- *out = buffer_move(&bufout);
- if (err)
- *err = buffer_move(&buferr);
- buffer_release(&bufout);
- buffer_release(&buferr);
+ if (out) *out = bufout.data;
+ if (err) *err = buferr.data;
return status;
}