summaryrefslogtreecommitdiff
path: root/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'common.c')
-rw-r--r--common.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/common.c b/common.c
index 4830206..5170943 100644
--- a/common.c
+++ b/common.c
@@ -1,16 +1,38 @@
+#include <stddef.h>
+#include <gc.h>
+
#include "debug.h"
-char *debug_int(char *i) {
+void *inter_main(void);
+
+void *debug_int(void *i) {
int *p = (int *) i;
debug("%d\n", *p);
return i;
}
-char *debug_str(char *s) {
- debug("%s\n", s);
- return s;
+void *gc_alloc(int size) {
+ void *p = GC_MALLOC(size);
+
+ /*
+ * To get info about the GC discarding objects, use
+ * GC_REGISTER_FINALIZER(p, fn, arg, 0, 0);
+ *
+ * This runs fn(p, arg) when the object at p is finalised.
+ *
+ * More info in gc.h of Boehm garbage collector.
+ */
+
+ return p;
}
-int int_if(int p, int a, int b) {
- return p ? a : b;
+int main() {
+
+ /*
+ * Initialising the GC is not necessary on all systems but may be required
+ * on some. Better safe than sorry! See gc.h for more info.
+ */
+ GC_INIT();
+
+ return (int) inter_main();
}