diff options
-rw-r--r-- | tests/test_table.cc | 2 | ||||
-rw-r--r-- | upb/bindings/lua/upb.c | 12 | ||||
-rw-r--r-- | upb/table.c | 2 |
3 files changed, 14 insertions, 2 deletions
diff --git a/tests/test_table.cc b/tests/test_table.cc index 9cc98b1..2cc5636 100644 --- a/tests/test_table.cc +++ b/tests/test_table.cc @@ -275,7 +275,7 @@ void test_inttable(int32_t *keys, uint16_t num_entries, const char *desc) { if (x == INT_MAX) abort(); printf("%ld/s (%0.1f%% of upb)\n\n", (long)(i/total), i / upb_rand_i); upb_inttable_uninit(&table); - delete rand_order; + delete[] rand_order; } int32_t *get_contiguous_keys(int32_t num) { diff --git a/upb/bindings/lua/upb.c b/upb/bindings/lua/upb.c index b35af24..02057d4 100644 --- a/upb/bindings/lua/upb.c +++ b/upb/bindings/lua/upb.c @@ -1358,6 +1358,18 @@ static size_t align_up(size_t val, size_t align) { // If we always read/write as a consistent type to each value, this shouldn't // violate aliasing. +// +// Note that the slightly prettier option of: +// +// *(type*)(&msg->data[ofs]) +// +// ...is potentially more questionable wrt the C standard and aliasing. +// Does the expression &msg->data[ofs] "access the stored value"? If so, +// this would violate aliasing. So instead we use the expression: +// +// (char*)msg + sizeof(lupb_msg) + ofs +// +// ...which unambigiously is doing nothing but calculating a pointer address. #define DEREF(msg, ofs, type) *(type*)((char*)msg + sizeof(lupb_msg) + ofs) lupb_msg *lupb_msg_check(lua_State *L, int narg) { diff --git a/upb/table.c b/upb/table.c index 9914a03..1bccfc7 100644 --- a/upb/table.c +++ b/upb/table.c @@ -542,7 +542,7 @@ void upb_inttable_compact(upb_inttable *t) { counts[log2ceil(key)]++; } - size_t arr_size = 1; + size_t arr_size; int arr_count = upb_inttable_count(t); if (upb_inttable_count(t) >= max_key * MIN_DENSITY) { |