Skip to content

Commit

Permalink
Merge pull request #31 from kivikakk/latest
Browse files Browse the repository at this point in the history
latest cbits
  • Loading branch information
kivikakk authored Aug 28, 2023
2 parents d86458c + c0f02ad commit aa68bba
Show file tree
Hide file tree
Showing 32 changed files with 14,838 additions and 10,802 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ cabal.sandbox.config
cabal.config
stack.yaml.lock
.stack-work/
dist-newstyle
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ cbits/cmark-gfm_export.h: $(CMARK_DIR)/build/src/cmark-gfm_export.h
cbits/cmark-gfm_version.h: $(CMARK_DIR)/build/src/cmark-gfm_version.h
cp $< $@

cbits/cmark-gfm-extensions_export.h: $(CMARK_DIR)/build/extensions/cmark-gfm-extensions_export.h
cp $< $@

cbits/%: $(CMARK_DIR)/src/%
cp $< $@

Expand Down
17 changes: 9 additions & 8 deletions cbits/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 All @@ -98,6 +99,6 @@ static void arena_free(void *ptr) {

cmark_mem CMARK_ARENA_MEM_ALLOCATOR = {arena_calloc, arena_realloc, arena_free};

cmark_mem *cmark_get_arena_mem_allocator() {
cmark_mem *cmark_get_arena_mem_allocator(void) {
return &CMARK_ARENA_MEM_ALLOCATOR;
}
Loading

0 comments on commit aa68bba

Please sign in to comment.