+ editor removes per-buffer fields. + switching from internal use of 'int' to 'size_t'. + deleting old code + double checking relevancy of comments. A lot has changed in 5 years, even more so in the past week. + fixing a few vestigal memory errors from the overhaul. + fixing search behavior
31 lines
574 B
C
31 lines
574 B
C
/*
|
|
* abuf.h - append/prepend buffer utilities
|
|
*/
|
|
#ifndef KE_ABUF_H
|
|
#define KE_ABUF_H
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
typedef struct abuf {
|
|
char *b;
|
|
size_t size;
|
|
size_t cap;
|
|
} abuf;
|
|
|
|
|
|
#define ABUF_INIT {NULL, 0, 0}
|
|
|
|
|
|
void ab_init(abuf *buf);
|
|
void ab_init_cap(abuf *buf, size_t cap);
|
|
void ab_resize(abuf *buf, size_t cap);
|
|
void ab_appendch(abuf *buf, char c);
|
|
void ab_append(abuf *buf, const char *s, size_t len);
|
|
void ab_prependch(abuf *buf, const char c);
|
|
void ab_prepend(abuf *buf, const char *s, const size_t len);
|
|
void ab_free(abuf *buf);
|
|
|
|
|
|
#endif
|