Handle WS fragmentation

This commit is contained in:
Sergey Lyubka committed 2021-08-27 10:25:24 +01:00
1 parent 7ba6fda236
commit 714b7a8145
7 files changed
+155 -38

No files matched your search

+9 -4
View File
@@ -56,14 +56,19 @@ size_t mg_iobuf_append(struct mg_iobuf *io, const void *buf, size_t len,
return len;
}
size_t mg_iobuf_delete(struct mg_iobuf *io, size_t len) {
if (len > io->len) len = io->len;
memmove(io->buf, io->buf + len, io->len - len);
zeromem(io->buf + io->len - len, len);
size_t mg_iobuf_del(struct mg_iobuf *io, size_t ofs, size_t len) {
if (ofs > io->len) ofs = io->len;
if (ofs + len > io->len) len = io->len - ofs;
memmove(io->buf + ofs, io->buf + ofs + len, io->len - ofs - len);
zeromem(io->buf + ofs + io->len - len, len);
io->len -= len;
return len;
}
size_t mg_iobuf_delete(struct mg_iobuf *io, size_t len) {
return mg_iobuf_del(io, 0, len);
}
void mg_iobuf_free(struct mg_iobuf *io) {
mg_iobuf_resize(io, 0);
}