Idris2-boot/tests/chez/chez013/struct.c
Edwin Brady a5c356f998 Basic support for struct in FFI
Just in the Chez backend for now, and not allowing strings or functions
due to limitations of Chez.
2020-03-01 23:23:21 +00:00

33 lines
507 B
C

#include <stdlib.h>
#include <stdio.h>
#include "struct.h"
char* getString(void *p) {
return (char*)p;
}
point* mkPoint(int x, int y) {
point* pt = malloc(sizeof(point));
pt->x = x;
pt->y = y;
return pt;
}
void freePoint(point* pt) {
free(pt);
}
namedpoint* mkNamedPoint(char* str, point* p) {
namedpoint* np = malloc(sizeof(namedpoint));
np->name = str;
np->pt = p;
printf("Made it!\n");
return np;
}
void freeNamedPoint(namedpoint* np) {
free(np);
}