mirror of https://git.kore.io/kore.git
Merge branch 'kore_buf_noalloc' of https://github.com/raphaelmonrouzeau/kore into raphaelmonrouzeau-kore_buf_noalloc
This commit is contained in:
commit
7cf73b5fa5
|
@ -1,7 +1,9 @@
|
|||
kore
|
||||
*.o
|
||||
*.swp
|
||||
*.swo
|
||||
*.module
|
||||
*.DSYM
|
||||
cert
|
||||
obj
|
||||
.lvimrc
|
||||
|
|
|
@ -623,9 +623,11 @@ void net_send_stream(struct connection *, void *,
|
|||
|
||||
void kore_buf_free(struct kore_buf *);
|
||||
struct kore_buf *kore_buf_create(size_t);
|
||||
void kore_buf_init(struct kore_buf *, size_t);
|
||||
void kore_buf_append(struct kore_buf *, const void *, size_t);
|
||||
u_int8_t *kore_buf_release(struct kore_buf *, size_t *);
|
||||
void kore_buf_reset(struct kore_buf *);
|
||||
void kore_buf_destroy(struct kore_buf *);
|
||||
|
||||
char *kore_buf_stringify(struct kore_buf *, size_t *);
|
||||
void kore_buf_appendf(struct kore_buf *, const char *, ...);
|
||||
|
|
20
src/buf.c
20
src/buf.c
|
@ -27,11 +27,17 @@ kore_buf_create(size_t initial)
|
|||
struct kore_buf *buf;
|
||||
|
||||
buf = kore_malloc(sizeof(*buf));
|
||||
kore_buf_init(buf, initial);
|
||||
|
||||
return (buf);
|
||||
}
|
||||
|
||||
void
|
||||
kore_buf_init(struct kore_buf *buf, size_t initial)
|
||||
{
|
||||
buf->data = kore_malloc(initial);
|
||||
buf->length = initial;
|
||||
buf->offset = 0;
|
||||
|
||||
return (buf);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -126,6 +132,16 @@ kore_buf_free(struct kore_buf *buf)
|
|||
kore_free(buf);
|
||||
}
|
||||
|
||||
void
|
||||
kore_buf_destroy(struct kore_buf *buf)
|
||||
{
|
||||
if (buf->data)
|
||||
kore_mem_free(buf->data);
|
||||
buf->data = NULL;
|
||||
buf->offset = 0;
|
||||
buf->length = 0;
|
||||
}
|
||||
|
||||
void
|
||||
kore_buf_replace_string(struct kore_buf *b, char *src, void *dst, size_t len)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue