From 694d51f4d6cb8adf4a2f7975e5bb899327875de7 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Mon, 3 Sep 2018 15:06:43 -0700 Subject: Changed C API to only define structs, a table, and a few minimal inline functions. --- upb/encode.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'upb/encode.c') diff --git a/upb/encode.c b/upb/encode.c index 24d72a8..d38676d 100644 --- a/upb/encode.c +++ b/upb/encode.c @@ -47,7 +47,7 @@ static uint32_t upb_zzencode_32(int32_t n) { return (n << 1) ^ (n >> 31); } static uint64_t upb_zzencode_64(int64_t n) { return (n << 1) ^ (n >> 63); } typedef struct { - upb_env *env; + upb_alloc *alloc; char *buf, *ptr, *limit; } upb_encstate; @@ -62,7 +62,7 @@ static size_t upb_roundup_pow2(size_t bytes) { static bool upb_encode_growbuffer(upb_encstate *e, size_t bytes) { size_t old_size = e->limit - e->buf; size_t new_size = upb_roundup_pow2(bytes + (e->limit - e->ptr)); - char *new_buf = upb_env_realloc(e->env, e->buf, old_size, new_size); + char *new_buf = upb_realloc(e->alloc, e->buf, old_size, new_size); CHK(new_buf); /* We want previous data at the end, realloc() put it at the beginning. */ @@ -371,10 +371,10 @@ bool upb_encode_message(upb_encstate *e, const char *msg, return true; } -char *upb_encode(const void *msg, const upb_msglayout *m, upb_env *env, +char *upb_encode(const void *msg, const upb_msglayout *m, upb_arena *arena, size_t *size) { upb_encstate e; - e.env = env; + e.alloc = upb_arena_alloc(arena); e.buf = NULL; e.limit = NULL; e.ptr = NULL; -- cgit v1.2.3