Skip to content

Commit

Permalink
First attempt support C99 compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
ohler55 committed Aug 11, 2021
1 parent 4cd3b31 commit 46c6fd3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
4 changes: 4 additions & 0 deletions 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.
Expand Down
21 changes: 12 additions & 9 deletions ext/oj/cache.c
Expand Up @@ -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;
}
Expand All @@ -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);
}
Expand All @@ -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);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/oj/version.rb
@@ -1,5 +1,5 @@

module Oj
# Current version of the module.
VERSION = '3.13.1'
VERSION = '3.13.2'
end

0 comments on commit 46c6fd3

Please sign in to comment.