njvm/support.c
nilspolek 815db27637 gc
2024-01-28 21:59:21 +01:00

30 lines
616 B
C

#include "support.h"
#include <stdio.h>
#include <stdlib.h>
#include "objref.c"
#include "njvm.h"
void fatalError(char *msg){
printf("Fatal error: %s\n", msg);
exit(1);
}
void * newPrimObject(int dataSize) {
ObjRef bigObjRef;
bigObjRef = alloc(sizeof(unsigned int) +
dataSize * sizeof(unsigned char));
if (bigObjRef == NULL) {
fatalError("newPrimObject() got no memory");
}
bigObjRef->size = sizeof(unsigned int) + dataSize * sizeof(unsigned char);
return bigObjRef;
}
void * getPrimObjectDataPointer(void * obj){
ObjRef oo = ((ObjRef) (obj));
return oo->data;
}