Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove the implicit +1 from op_len.

The inconsistency between op_len and gc_alloc is really confusing. Remove
it.
  • Loading branch information...
commit a60faba6c8ace285c14fd62681d9c30ae71a5e69 1 parent addbe4a
@nelhage authored
Showing with 8 additions and 8 deletions.
  1. +4 −4 gc.c
  2. +4 −4 scgc.c
View
8 gc.c
@@ -114,7 +114,7 @@ static void gc_relocate_external_roots(gc_external_roots *v) {
}
static uint32_t gc_len_external_roots(gc_external_roots *v) {
- return v->nroots + 2;
+ return v->nroots + sizeof(gc_external_roots)/sizeof(gc_handle);
}
static gc_ops gc_external_root_ops = {
@@ -191,7 +191,7 @@ static void gc_relocate_root_hook(gc_root_hook *hook) {
}
static uint32_t gc_len_root_hook(gc_chunk *chunk) {
- return 2;
+ return sizeof(gc_root_hook)/sizeof(gc_handle);
}
static struct gc_ops gc_root_hook_ops = {
@@ -227,7 +227,7 @@ void gc_relocate(gc_handle *v) {
assert(val->ops);
- len = val->ops->op_len(val) + 1;
+ len = val->ops->op_len(val);
reloc = _gc_alloc(len);
memcpy(reloc, val, sizeof(uintptr_t) * len);
@@ -284,7 +284,7 @@ void gc_gc() {
assert(chunk->ops);
chunk->ops->op_relocate(chunk);
- scan += chunk->ops->op_len(chunk) + 1;
+ scan += chunk->ops->op_len(chunk);
if(scan > working_mem + mem_size) {
printf("GC internal error -- ran off the end of memory!\n");
View
8 scgc.c
@@ -35,19 +35,19 @@ typedef struct sc_boolean {
/* Op functions */
uint32_t sc_len_string(gc_chunk *v) {
- return 1 + STRLEN2CELLS(((sc_string*)v)->strlen);
+ return sizeof(sc_string)/sizeof(gc_handle) + STRLEN2CELLS(((sc_string*)v)->strlen);
}
uint32_t sc_len_cons(gc_chunk *v UNUSED) {
- return 2;
+ return sizeof(sc_cons)/sizeof(gc_handle);
}
uint32_t sc_len_vector(gc_chunk *v) {
- return 1 + ((sc_vector*)v)->veclen;
+ return sizeof(sc_vector)/sizeof(gc_handle) + ((sc_vector*)v)->veclen;
}
uint32_t sc_len_boolean(gc_chunk *v UNUSED) {
- return 1;
+ return sizeof(sc_boolean)/sizeof(gc_handle);
}
void sc_relocate_cons(gc_chunk *v) {
Please sign in to comment.
Something went wrong with that request. Please try again.