Include memory fixes from main branch

This commit is contained in:
sle118
2019-08-29 09:16:00 -04:00
parent 6e7793a756
commit 4a4614951e
23 changed files with 406 additions and 327 deletions

View File

@@ -64,6 +64,11 @@ void buf_flush(struct buffer *buf) {
mutex_unlock(buf->mutex);
}
void _buf_flush(struct buffer *buf) {
buf->readp = buf->buf;
buf->writep = buf->buf;
}
// adjust buffer to multiple of mod bytes so reading in multiple always wraps on frame boundary
void buf_adjust(struct buffer *buf, size_t mod) {
size_t size;
@@ -78,6 +83,7 @@ void buf_adjust(struct buffer *buf, size_t mod) {
// called with mutex locked to resize, does not retain contents, reverts to original size if fails
void _buf_resize(struct buffer *buf, size_t size) {
if (size == buf->size) return;
free(buf->buf);
buf->buf = malloc(size);
if (!buf->buf) {