formatting/style

This commit is contained in:
Andrew Scott 2024-09-06 11:05:16 -04:00
parent 0747e78b15
commit 26ef0bc3ad
Signed by: a
GPG key ID: 7CD5A5977E4931C1
6 changed files with 205 additions and 202 deletions

View file

@ -43,5 +43,6 @@ void collect(struct virtualMachine *vm)
{
markAll(vm);
sweep(vm);
vm->refMax = vm->refCount * 2 <= STACK_MAX ? vm->refCount * 2 : STACK_MAX;
vm->refMax = vm->refCount * 2 <= STACK_MAX ? vm->refCount * 2 :
STACK_MAX;
}

View file

@ -5,7 +5,8 @@
static void *allocHead = NULL;
struct gcHeader *findFree(struct gcHeader **prev, size_t size) {
struct gcHeader *findFree(struct gcHeader **prev, size_t size)
{
struct gcHeader *curr = allocHead;
while (curr && !(curr->free && curr->size >= size)) {
@ -16,7 +17,8 @@ struct gcHeader *findFree(struct gcHeader **prev, size_t size) {
return curr;
}
struct gcHeader *requestMem(struct gcHeader *prev, size_t size) {
struct gcHeader *requestMem(struct gcHeader *prev, size_t size)
{
struct gcHeader *block;
void *request;

View file

@ -12,8 +12,8 @@ void test_int_alloc(void)
pushInt(vm, 1000);
pushInt(vm, 10000);
pushInt(vm, -100000);
assert(vm->refCount == 4
&& "test_int_alloc: GARBAGE_INT allocation failure\n");
assert(vm->refCount == 4 &&
"test_int_alloc: GARBAGE_INT allocation failure\n");
printf("test_int_alloc: PASS\n");
deinitVM(vm);
}
@ -27,8 +27,8 @@ void test_pair_alloc(void)
pushInt(vm, -100000);
pushPair(vm);
pushPair(vm);
assert(vm->refCount == 6
&& "test_pair_alloc: FAILED: GARBAGE_PAIR allocation failure\n");
assert(vm->refCount == 6 &&
"test_pair_alloc: FAILED: GARBAGE_PAIR allocation failure\n");
printf("test_pair_alloc: PASS\n");
deinitVM(vm);
}
@ -41,8 +41,8 @@ void test_obj_count(void)
pushInt(vm, 10000);
pushInt(vm, -100000);
collect(vm);
assert(vm->refCount == 4
&& "test_obj_count: FAILED: GC occurred when it shouldn't have\n");
assert(vm->refCount == 4 &&
"test_obj_count: FAILED: GC occurred when it shouldn't have\n");
printf("test_obj_count: PASS\n");
deinitVM(vm);
}
@ -58,8 +58,8 @@ void test_nested_pair(void)
pushPair(vm);
pushPair(vm);
collect(vm);
assert(vm->refCount == 7
&& "test_nested_pair: FAILED: GARBAGE_PAIR allocation failure\n");
assert(vm->refCount == 7 &&
"test_nested_pair: FAILED: GARBAGE_PAIR allocation failure\n");
printf("test_pair_alloc: PASS\n");
deinitVM(vm);
}
@ -72,9 +72,8 @@ void test_unreachable(void)
pop(vm);
pop(vm);
collect(vm);
assert(
vm->refCount == 0
&& "test_unreachable: FAILED: 2 GARBAGE_INT should have been freed\n");
assert(vm->refCount == 0 &&
"test_unreachable: FAILED: 2 GARBAGE_INT should have been freed\n");
printf("test_unreachable: PASS\n");
deinitVM(vm);
}
@ -95,8 +94,8 @@ void test_auto_gc(void)
pushInt(vm, 2);
}
assert(vm->refCount == 550
&& "test_auto_gc: FAILED: 5 references should have been freed\n");
assert(vm->refCount == 550 &&
"test_auto_gc: FAILED: 5 references should have been freed\n");
printf("test_auto_gc: PASS\n");
deinitVM(vm);
}

View file

@ -24,7 +24,8 @@ void deinitVM(struct virtualMachine *vm)
void push(struct virtualMachine *vm, struct garbageObject *value)
{
if (vm->stackSize >= STACK_MAX) {
fprintf(stderr, "ERROR: push(): refusing to overflow the stack!\n");
fprintf(stderr,
"ERROR: push(): refusing to overflow the stack!\n");
return;
}
vm->stack[vm->stackSize++] = value;