junie-undo
This commit is contained in:
35
abuf.c
35
abuf.c
@@ -1,6 +1,7 @@
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint-gcc.h>
|
||||
|
||||
#include "abuf.h"
|
||||
#include "core.h"
|
||||
@@ -36,6 +37,16 @@ ab_init_cap(abuf *buf, const size_t cap)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ab_init_str(abuf *buf, const char *s)
|
||||
{
|
||||
size_t len = kstrnlen(s, SIZE_MAX);
|
||||
|
||||
ab_init_cap(buf, len);
|
||||
ab_append(buf, s, len);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ab_resize(abuf *buf, size_t cap)
|
||||
{
|
||||
@@ -71,6 +82,18 @@ ab_append(abuf *buf, const char *s, size_t len)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ab_append_ab(abuf *buf, abuf *other)
|
||||
{
|
||||
assert(buf != NULL && other != NULL);
|
||||
if (other->size == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ab_append(buf, other->b, other->size);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ab_prependch(abuf *buf, const char c)
|
||||
{
|
||||
@@ -97,6 +120,18 @@ ab_prepend(abuf *buf, const char *s, const size_t len)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ab_prepend_ab(abuf *buf, abuf *other)
|
||||
{
|
||||
assert(buf != NULL && other != NULL);
|
||||
if (other->size == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ab_prepend(buf, other->b, other->size);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ab_free(abuf *buf)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user