summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEkaitz Zarraga <ekaitz@elenq.tech>2025-08-22 00:38:36 +0200
committerEkaitz Zarraga <ekaitz@elenq.tech>2025-08-22 00:38:36 +0200
commit39dd684496a6750a2458873e3c736bd8569e8db0 (patch)
tree171f2d0ab8094eb83e183e64de4385260ea228cd /src
parentebb4cc5b97b8565ceffa0d48301f8af9e6b884df (diff)
text-buffer: Add `text_buffer_append_str` function
Diffstat (limited to 'src')
-rw-r--r--src/piece-table.c6
-rw-r--r--src/text-buffer.c10
-rw-r--r--src/text-buffer.h1
3 files changed, 12 insertions, 5 deletions
diff --git a/src/piece-table.c b/src/piece-table.c
index 070d265..14f456f 100644
--- a/src/piece-table.c
+++ b/src/piece-table.c
@@ -159,15 +159,11 @@ void
piece_table_insert (piece_table *pt, size_t pos, char *in, size_t len)
{
piece *start, *end, *new;
- size_t i;
assert ( pos <= pt->length );
assert ( len > 0 );
- for (i=0; i<len; i++)
- {
- text_buffer_append (&pt->add, in[i]);
- }
+ text_buffer_append_str (&pt->add, in, len);
if ( pos == 0 )
{
diff --git a/src/text-buffer.c b/src/text-buffer.c
index 215e446..cc764bc 100644
--- a/src/text-buffer.c
+++ b/src/text-buffer.c
@@ -47,6 +47,16 @@ text_buffer_append (text_buffer *tb, char c)
tb->contents[tb->used++] = c;
}
+void
+text_buffer_append_str (text_buffer *tb, char *c, size_t len)
+{
+ size_t i;
+ for (i=0; i<len; i++)
+ {
+ text_buffer_append (tb, c[i]);
+ }
+}
+
char
text_buffer_index (text_buffer *tb, size_t pos)
{
diff --git a/src/text-buffer.h b/src/text-buffer.h
index 3c85816..61a01c2 100644
--- a/src/text-buffer.h
+++ b/src/text-buffer.h
@@ -36,6 +36,7 @@ text_buffer;
void text_buffer_init (text_buffer *tb);
void text_buffer_resize (text_buffer *tb, size_t size);
void text_buffer_append (text_buffer *tb, char c);
+void text_buffer_append_str (text_buffer *tb, char *c, size_t len);
char text_buffer_index (text_buffer *tb, size_t pos);
void text_buffer_fill (text_buffer *tb, char *fill, size_t size);
void text_buffer_clear (text_buffer *tb);