2020-12-05 19:26:32 +08:00
|
|
|
#pragma once
|
|
|
|
|
2022-07-02 00:28:06 +08:00
|
|
|
#include "arch.h"
|
2020-12-05 19:26:32 +08:00
|
|
|
|
|
|
|
struct mg_iobuf {
|
2021-08-30 20:06:45 +08:00
|
|
|
unsigned char *buf; // Pointer to stored data
|
2021-08-28 15:08:54 +08:00
|
|
|
size_t size; // Total size available
|
|
|
|
size_t len; // Current number of bytes
|
2022-08-01 19:53:25 +08:00
|
|
|
size_t align; // Alignment during allocation
|
2020-12-05 19:26:32 +08:00
|
|
|
};
|
|
|
|
|
2022-08-01 19:53:25 +08:00
|
|
|
int mg_iobuf_init(struct mg_iobuf *, size_t, size_t);
|
2021-01-29 20:32:34 +08:00
|
|
|
int mg_iobuf_resize(struct mg_iobuf *, size_t);
|
2020-12-05 19:26:32 +08:00
|
|
|
void mg_iobuf_free(struct mg_iobuf *);
|
2022-08-01 19:53:25 +08:00
|
|
|
size_t mg_iobuf_add(struct mg_iobuf *, size_t, const void *, size_t);
|
2021-08-27 17:25:24 +08:00
|
|
|
size_t mg_iobuf_del(struct mg_iobuf *, size_t ofs, size_t len);
|