diff options
author | Joshua Haberman <jhaberman@gmail.com> | 2018-09-03 15:06:43 -0700 |
---|---|---|
committer | Joshua Haberman <jhaberman@gmail.com> | 2018-09-03 15:06:43 -0700 |
commit | 694d51f4d6cb8adf4a2f7975e5bb899327875de7 (patch) | |
tree | 29ea62eeb151c4cfc739522e19ee30dbee57a137 /upb/encode.c | |
parent | 41379a7064b6488099f203521fb69ceea0f6cc15 (diff) |
Changed C API to only define structs, a table, and a few minimal inline functions.
Diffstat (limited to 'upb/encode.c')
-rw-r--r-- | upb/encode.c | 8 |
1 files changed, 4 insertions, 4 deletions
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; |