njvm/support.c
2024-01-28 17:32:30 +01:00

33 lines
659 B
C

#ifndef SUPPORT_C
#define SUPPORT_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;
}
#endif