From 46c6fd304b0d4783111c21bcad9ad32440c69ead Mon Sep 17 00:00:00 2001 From: Peter Ohler Date: Tue, 10 Aug 2021 21:29:19 -0400 Subject: [PATCH] First attempt support C99 compiler --- CHANGELOG.md | 4 ++++ ext/oj/cache.c | 21 ++++++++++++--------- lib/oj/version.rb | 2 +- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3ea6026..647fbdd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 3.13.2 - 2021-08-11 + +- Fixed C99 compiler errors. + ## 3.13.1 - 2021-08-09 - Fixed failing build on Windows. diff --git a/ext/oj/cache.c b/ext/oj/cache.c index a60650a5..ebaf10d9 100644 --- a/ext/oj/cache.c +++ b/ext/oj/cache.c @@ -98,31 +98,30 @@ Cache cache_create(size_t size, VALUE (*form)(const char *str, size_t len), bool memset(c->slots, 0, sizeof(Slot) * c->size); c->form = form; c->cnt = 0; - c->mark = mark; + c->mark = mark; return c; } static void rehash(Cache c) { uint32_t osize = c->size; + Slot * end = c->slots + osize; + Slot * sp; c->size = osize * 4; c->mask = c->size - 1; REALLOC_N(c->slots, Slot, c->size); memset(c->slots + osize, 0, sizeof(Slot) * osize * 3); - - Slot *end = c->slots + osize; - for (Slot *sp = c->slots; sp < end; sp++) { + for (sp = c->slots; sp < end; sp++) { Slot s = *sp; Slot next = NULL; *sp = NULL; for (; NULL != s; s = next) { - next = s->next; - uint32_t h = s->hash & c->mask; Slot * bucket = c->slots + h; + next = s->next; s->next = *bucket; *bucket = s; } @@ -132,7 +131,9 @@ static void rehash(Cache c) { void cache_free(Cache c) { for (uint32_t i = 0; i < c->size; i++) { Slot next; - for (Slot s = c->slots[i]; NULL != s; s = next) { + Slot s; + + for (s = c->slots[i]; NULL != s; s = next) { next = s->next; xfree(s); } @@ -143,9 +144,11 @@ void cache_free(Cache c) { void cache_mark(Cache c) { if (c->mark) { - for (uint32_t i = 0; i < c->size; i++) { + uint32_t i; + + for (i = 0; i < c->size; i++) { for (Slot s = c->slots[i]; NULL != s; s = s->next) { - rb_gc_mark(s->val); + rb_gc_mark(s->val); } } } diff --git a/lib/oj/version.rb b/lib/oj/version.rb index 0957d072..bb99a607 100644 --- a/lib/oj/version.rb +++ b/lib/oj/version.rb @@ -1,5 +1,5 @@ module Oj # Current version of the module. - VERSION = '3.13.1' + VERSION = '3.13.2' end