summaryrefslogtreecommitdiff
path: root/upb/env.c
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2015-05-08 17:20:55 -0700
committerJosh Haberman <jhaberman@gmail.com>2015-05-08 17:20:55 -0700
commit838009ba2b8ea1e99061c66e0fbd9cb53a96ec20 (patch)
treeda3cbc97eed1eb70af5e0f3a687ff37ad239d119 /upb/env.c
parentfa10302a502de38a66ed921eeeacb4107e9572a2 (diff)
Fixes for the open-source build.
Diffstat (limited to 'upb/env.c')
-rw-r--r--upb/env.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/upb/env.c b/upb/env.c
index ae5fb85..7fa3334 100644
--- a/upb/env.c
+++ b/upb/env.c
@@ -43,7 +43,7 @@ static void *default_alloc(void *_ud, void *ptr, size_t oldsize, size_t size) {
UPB_UNUSED(oldsize);
default_alloc_ud *ud = _ud;
- mem_block *from = ptr ? ptr - sizeof(mem_block) : NULL;
+ mem_block *from = ptr ? (void*)((char*)ptr - sizeof(mem_block)) : NULL;
#ifndef NDEBUG
if (from) {
@@ -214,7 +214,9 @@ UPB_FORCEINLINE static void *seeded_alloc(void *ud, void *ptr, size_t oldsize,
upb_seededalloc *a = ud;
size = align_up(size);
- if (oldsize == 0 && size <= a->mem_limit - a->mem_ptr) {
+ assert(a->mem_limit >= a->mem_ptr);
+
+ if (oldsize == 0 && size <= (size_t)(a->mem_limit - a->mem_ptr)) {
// Fast path: we can satisfy from the initial allocation.
void *ret = a->mem_ptr;
a->mem_ptr += size;
@@ -229,7 +231,7 @@ UPB_FORCEINLINE static void *seeded_alloc(void *ud, void *ptr, size_t oldsize,
void upb_seededalloc_init(upb_seededalloc *a, void *mem, size_t len) {
a->mem_base = mem;
a->mem_ptr = mem;
- a->mem_limit = mem + len;
+ a->mem_limit = (char*)mem + len;
a->need_cleanup = false;
a->returned_allocfunc = false;
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback