diff options
author | Michael Pavone <pavone@retrodev.com> | 2020-04-29 01:00:57 -0700 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2020-04-29 01:00:57 -0700 |
commit | 2071d8e545b9aca6af08852f721e9a7b7a617398 (patch) | |
tree | 75148c6c893661c0e6b0bada4c7ca5b71cd8255d /serialize.c | |
parent | 6641d3825bb931c5af37b98fc6420c972cfb3fd1 (diff) |
WIP netplay support
Diffstat (limited to 'serialize.c')
-rw-r--r-- | serialize.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/serialize.c b/serialize.c index dc54bb8..a59151f 100644 --- a/serialize.c +++ b/serialize.c @@ -20,8 +20,13 @@ void init_serialize(serialize_buffer *buf) static void reserve(serialize_buffer *buf, size_t amount) { if (amount > (buf->storage - buf->size)) { - buf->storage *= 2; - buf = realloc(buf, buf->storage + sizeof(*buf)); + if (amount < buf->storage) { + buf->storage *= 2; + } else { + //doublign isn't enough, increase by the precise amount needed + buf->storage += amount - (buf->storage - buf->size); + } + buf->data = realloc(buf->data, buf->storage + sizeof(*buf)); } } |