start working on runtime

This commit is contained in:
2025-06-20 02:50:05 +01:00
parent e5e4f22481
commit bddfb59886
7 changed files with 55 additions and 10 deletions

View File

@@ -1,13 +1,14 @@
#include "hashmap.h"
#include <gc/gc.h>
#include <stdlib.h>
#include "../memory.h"
struct table *createTable(int size)
{
struct table *t = (struct table *)checked_malloc(sizeof(struct table));
struct table *t = (struct table *)ar_alloc(sizeof(struct table));
t->size = size;
t->list = (struct node **)checked_malloc(sizeof(struct node *) * size);
t->list = (struct node **)ar_alloc(sizeof(struct node *) * size);
int i;
for (i = 0; i < size; i++)
t->list[i] = NULL;
@@ -49,7 +50,7 @@ void insert(struct table *t, int key, void* val)
{
int pos = hashCode(t, key);
struct node *list = t->list[pos];
struct node *newNode = (struct node *)checked_malloc(sizeof(struct node));
struct node *newNode = (struct node *)ar_alloc(sizeof(struct node));
struct node *temp = list;
while (temp)
{