Skip to content
This repository has been archived by the owner on Jun 4, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into releases
Browse files Browse the repository at this point in the history
  • Loading branch information
be5invis committed Aug 19, 2016
2 parents 58e9855 + 0b9dbf7 commit 5086d45
Show file tree
Hide file tree
Showing 13 changed files with 660 additions and 104 deletions.
10 changes: 5 additions & 5 deletions lib/bk/bkblock.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "bkblock.h"

static void bkblock_acells(caryll_bkblock *b, size_t len) {
static void bkblock_acells(caryll_bkblock *b, uint32_t len) {
if (len <= b->length + b->free) {
// We have enough space
b->free -= len - b->length;
Expand All @@ -20,8 +20,8 @@ bool bk_cell_is_ptr(bk_cell *cell) {
return cell->t >= p16;
}

static bk_cell *bkblock_grow(caryll_bkblock *b, size_t len) {
size_t olen = b->length;
static bk_cell *bkblock_grow(caryll_bkblock *b, uint32_t len) {
uint32_t olen = b->length;
bkblock_acells(b, olen + len);
return &(b->cells[olen]);
}
Expand All @@ -46,7 +46,7 @@ void bkblock_pushptr(caryll_bkblock *b, bk_cell_type type, caryll_bkblock *p) {
static void vbkpushitems(caryll_bkblock *b, bk_cell_type type0, va_list ap) {
bk_cell_type curtype = type0;
while (curtype) {
if (curtype == bembed) {
if (curtype == bkcopy || curtype == bkembed) {
caryll_bkblock *par = va_arg(ap, caryll_bkblock *);
if (par && par->cells) {
for (uint32_t j = 0; j < par->length; j++) {
Expand All @@ -57,7 +57,7 @@ static void vbkpushitems(caryll_bkblock *b, bk_cell_type type0, va_list ap) {
}
}
}
if (par) {
if (curtype == bkembed && par) {
free(par->cells);
free(par);
}
Expand Down
22 changes: 13 additions & 9 deletions lib/bk/bkblock.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@

struct __caryll_bkblock;
typedef enum {
bkover = 0, // nothing
b8 = 1, // byte
b16 = 2, // short
b32 = 3, // long
p16 = 0x10, // 16-bit offset, p = pointer to block
p32 = 0x11, // 32-bit offset, p = pointer to block
bembed = 0xFF // Embed another block
bkover = 0, // nothing
b8 = 1, // byte
b16 = 2, // short
b32 = 3, // long
p16 = 0x10, // 16-bit offset, p = pointer to block
p32 = 0x11, // 32-bit offset, p = pointer to block
sp16 = 0x80, // 16-bit offset, p = pointer to block, marked as compact
sp32 = 0x81, // 32-bit offset, p = pointer to block, marked as compact
bkcopy = 0xFE, // Embed another block
bkembed = 0xFF // Embed another block
} bk_cell_type;
typedef enum { VISIT_WHITE, VISIT_GRAY, VISIT_BLACK } bk_cell_visit_state;

Expand All @@ -31,8 +34,9 @@ typedef struct __caryll_bkblock {
bk_cell_visit_state _visitstate;
uint32_t _index;
uint32_t _height;
size_t length;
size_t free;
uint32_t _depth;
uint32_t length;
uint32_t free;
bk_cell *cells;
} caryll_bkblock;

Expand Down
Loading

0 comments on commit 5086d45

Please sign in to comment.