mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-28 12:30:58 +00:00
mg_iobuf_append -> mg_iobuf_add
This commit is contained in:
1 parent
913e730ec2
commit
477e48bf54
9 files changed
+67
-52
No files matched your search
+5
-3
@@ -42,8 +42,8 @@ int mg_iobuf_init(struct mg_iobuf *io, size_t size) {
|
||||
return mg_iobuf_resize(io, size);
|
||||
}
|
||||
|
||||
size_t mg_iobuf_append(struct mg_iobuf *io, const void *buf, size_t len,
|
||||
size_t chunk_size) {
|
||||
size_t mg_iobuf_add(struct mg_iobuf *io, size_t ofs, const void *buf,
|
||||
size_t len, size_t chunk_size) {
|
||||
size_t new_size = io->len + len;
|
||||
if (new_size > io->size) {
|
||||
new_size += chunk_size; // Make sure that io->size
|
||||
@@ -51,7 +51,9 @@ size_t mg_iobuf_append(struct mg_iobuf *io, const void *buf, size_t len,
|
||||
mg_iobuf_resize(io, new_size); // Attempt to realloc
|
||||
if (new_size != io->size) len = 0; // Realloc failure, append nothing
|
||||
}
|
||||
if (buf != NULL) memmove(io->buf + io->len, buf, len);
|
||||
if (ofs < io->len) memmove(io->buf + ofs + len, io->buf + ofs, io->len - ofs);
|
||||
if (buf != NULL) memmove(io->buf + ofs, buf, len);
|
||||
if (ofs > io->len) io->len += ofs - io->len;
|
||||
io->len += len;
|
||||
return len;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user