Skip to content

Commit

Permalink
Update cmark-upstream to github/cmark-gfm@57d5e09
Browse files Browse the repository at this point in the history
  • Loading branch information
phillmv committed Jan 24, 2023
1 parent 1cfec13 commit 9007c37
Show file tree
Hide file tree
Showing 16 changed files with 14,418 additions and 10,637 deletions.
15 changes: 8 additions & 7 deletions ext/commonmarker/arena.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,16 @@ static void *arena_calloc(size_t nmem, size_t size) {
const size_t align = sizeof(size_t) - 1;
sz = (sz + align) & ~align;

struct arena_chunk *chunk;
if (sz > A->sz) {
A->prev = alloc_arena_chunk(sz, A->prev);
return (uint8_t *) A->prev->ptr + sizeof(size_t);
A->prev = chunk = alloc_arena_chunk(sz, A->prev);
} else if (sz > A->sz - A->used) {
A = chunk = alloc_arena_chunk(A->sz + A->sz / 2, A);
} else {
chunk = A;
}
if (sz > A->sz - A->used) {
A = alloc_arena_chunk(A->sz + A->sz / 2, A);
}
void *ptr = (uint8_t *) A->ptr + A->used;
A->used += sz;
void *ptr = (uint8_t *) chunk->ptr + chunk->used;
chunk->used += sz;
*((size_t *) ptr) = sz - sizeof(size_t);
return (uint8_t *) ptr + sizeof(size_t);
}
Expand Down

0 comments on commit 9007c37

Please sign in to comment.