Clean errors in compilation when VERBOSE > 0
This commit is contained in:
@@ -72,6 +72,8 @@ typedef struct
|
|||||||
darr_t page_vec;
|
darr_t page_vec;
|
||||||
} heap_t;
|
} heap_t;
|
||||||
|
|
||||||
|
#define HEAP_SIZE(HEAP) ((HEAP).page_vec.used / sizeof(page_t *))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Instantiate a new heap structure
|
@brief Instantiate a new heap structure
|
||||||
|
|
||||||
|
|||||||
@@ -10,14 +10,10 @@
|
|||||||
* Description: Entrypoint to program
|
* Description: Entrypoint to program
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <lib/inst.h>
|
#include <vm/runtime.h>
|
||||||
|
#include <vm/struct.h>
|
||||||
#include "./runtime.h"
|
|
||||||
#include "./struct.h"
|
|
||||||
|
|
||||||
void usage(const char *program_name, FILE *out)
|
void usage(const char *program_name, FILE *out)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,6 +14,10 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#if VERBOSE >= 2
|
||||||
|
#include <string.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "./runtime.h"
|
#include "./runtime.h"
|
||||||
|
|
||||||
const char *err_as_cstr(err_t err)
|
const char *err_as_cstr(err_t err)
|
||||||
@@ -286,10 +290,10 @@ err_t vm_execute_all(vm_t *vm)
|
|||||||
"----------\n",
|
"----------\n",
|
||||||
stdout);
|
stdout);
|
||||||
}
|
}
|
||||||
if (prev_pages != vm->heap.pages)
|
if (prev_pages != HEAP_SIZE(vm->heap))
|
||||||
{
|
{
|
||||||
vm_print_heap(vm, stdout);
|
vm_print_heap(vm, stdout);
|
||||||
prev_pages = vm->heap.pages;
|
prev_pages = HEAP_SIZE(vm->heap);
|
||||||
fputs("------------------------------------------------------------------"
|
fputs("------------------------------------------------------------------"
|
||||||
"----"
|
"----"
|
||||||
"----------\n",
|
"----------\n",
|
||||||
|
|||||||
16
vm/struct.c
16
vm/struct.c
@@ -65,21 +65,21 @@ void vm_stop(vm_t *vm)
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (vm->heap.pages > 0)
|
if (HEAP_SIZE(vm->heap) > 0)
|
||||||
{
|
{
|
||||||
leaks = true;
|
const size_t size_pages = HEAP_SIZE(vm->heap);
|
||||||
page_t *cur = vm->heap.beg;
|
leaks = true;
|
||||||
size_t capacities[vm->heap.pages], total_capacity = 0;
|
size_t capacities[size_pages], total_capacity = 0;
|
||||||
for (size_t i = 0; i < vm->heap.pages; ++i)
|
for (size_t i = 0; i < size_pages; ++i)
|
||||||
{
|
{
|
||||||
|
page_t *cur = DARR_AT(page_t *, vm->heap.page_vec.data, i);
|
||||||
capacities[i] = cur->available;
|
capacities[i] = cur->available;
|
||||||
total_capacity += capacities[i];
|
total_capacity += capacities[i];
|
||||||
}
|
}
|
||||||
printf("\t[" TERM_RED "DATA" TERM_RESET
|
printf("\t[" TERM_RED "DATA" TERM_RESET
|
||||||
"]: Heap: %luB (over %lu %s) not reclaimed\n",
|
"]: Heap: %luB (over %lu %s) not reclaimed\n",
|
||||||
total_capacity, vm->heap.pages,
|
total_capacity, size_pages, size_pages == 1 ? "page" : "pages");
|
||||||
vm->heap.pages == 1 ? "page" : "pages");
|
for (size_t i = 0; i < size_pages; i++)
|
||||||
for (size_t i = 0; i < vm->heap.pages; i++)
|
|
||||||
printf("\t\t[%lu]: %luB lost\n", i, capacities[i]);
|
printf("\t\t[%lu]: %luB lost\n", i, capacities[i]);
|
||||||
}
|
}
|
||||||
if (vm->stack.ptr > 0)
|
if (vm->stack.ptr > 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user