Index: src/examples/gc_no_raii/cfa
===================================================================
--- src/examples/gc_no_raii/cfa	(revision 15db1ab4e18373801ab9f3db0366d4b4a0ba7e95)
+++ src/examples/gc_no_raii/cfa	(revision 15db1ab4e18373801ab9f3db0366d4b4a0ba7e95)
@@ -0,0 +1,1 @@
+../../../bin/cfa
Index: src/examples/gc_no_raii/gc-internal/object_header.h
===================================================================
--- src/examples/gc_no_raii/gc-internal/object_header.h	(revision 15db1ab4e18373801ab9f3db0366d4b4a0ba7e95)
+++ src/examples/gc_no_raii/gc-internal/object_header.h	(revision 15db1ab4e18373801ab9f3db0366d4b4a0ba7e95)
@@ -0,0 +1,26 @@
+#pragma once
+
+#include <stdint.h>
+
+#include "tools.h"
+
+static const void* CANARY_VALUE = (void*)0xCAFEBABACAFEBABA;
+
+struct gcpointer_t;
+
+struct gc_object_header
+{
+	#if _DEBUG
+		void* canary_start;
+	#endif
+
+	size_t		size;
+	gcpointer_t* 	root_chain;
+	gcpointer_t*	type_chain;
+	object_header*	forward;
+	bool			is_forwarded;
+
+	#if _DEBUG
+		void* canary_end;
+	#endif
+};
Index: src/examples/gc_no_raii/gc.h
===================================================================
--- src/examples/gc_no_raii/gc.h	(revision 15db1ab4e18373801ab9f3db0366d4b4a0ba7e95)
+++ src/examples/gc_no_raii/gc.h	(revision 15db1ab4e18373801ab9f3db0366d4b4a0ba7e95)
@@ -0,0 +1,9 @@
+#pragma once
+
+#include "gcpointers.h"
+
+forall( dtype T )
+gcpointer_t gcmalloc()
+{
+
+}
Index: src/examples/gc_no_raii/gcpointers.c
===================================================================
--- src/examples/gc_no_raii/gcpointers.c	(revision 15db1ab4e18373801ab9f3db0366d4b4a0ba7e95)
+++ src/examples/gc_no_raii/gcpointers.c	(revision 15db1ab4e18373801ab9f3db0366d4b4a0ba7e95)
@@ -0,0 +1,98 @@
+#include "gcpointers.h"
+
+#include "gc.h"
+
+void register_ptr(gcpointer_t* this)
+{
+	if(gcpointer_null(this)) return;
+
+	_Bool managed = gc_is_managed(this);
+
+	if(managed)
+	{
+		gc_object_header* obj = gc_get_object_for_ref(this);
+		check(obj);
+		check(gc_obj_is_valide(obj));
+		check(gc_is_managed(this) == gc_is_managed(obj->type_chain) || obj->type_chain == NULL);
+		m_next = obj->type_chain;
+		obj->type_chain = this;
+		check(obj->is_valide());
+	}
+	else
+	{
+		gc_object_header* obj = gc_get_object_ptr(this->ptr);
+		check(obj);
+		check(gc_obj_is_valide(obj));
+		check(gc_is_managed(this) == gc_is_managed(obj->root_chain) || obj->root_chain == NULL);
+		m_next = obj->root_chain;
+		obj->root_chain = this;
+		check(gc_obj_is_valide(obj));
+	}
+}
+
+void unregister_ptr(gcpointer_t* this)
+{
+	if(gcpointer_null(this)) return;
+
+	gcpointer_t** prev_next_ptr = gc_find_previous_ref(this);
+	check((*prev_next_ptr) == this);
+
+	(*prev_next_ptr) = this->next;
+}
+
+void gcpointer_ctor(gcpointer_t* this)
+{
+	this->ptr = NULL;
+	this->next = NULL;
+}
+
+void gcpointer_ctor(gcpointer_t* this, void* address)
+{
+	this->ptr = address;
+	this->next = NULL;
+
+	register_ptr(this);
+}
+
+void gcpointer_ctor(gcpointer_t* this, gcpointer_t* other)
+{
+	this->ptr = other->ptr;
+	this->next = NULL;
+
+	register_ptr(this);
+}
+
+void gcpointer_dtor(gcpointer_t* this)
+{
+	unregister_ptr(this);
+}
+
+gcpointer_t* gcpointer_assign(gcpointer_t* this, gcpointer_t* rhs)
+{
+	if(this != rhs && this->ptr != rhs->ptr)
+	{
+		unregister_ptr(this);
+
+		this->ptr = rhs->ptr;
+
+		register_ptr(this);
+	}
+
+	return this;
+}
+
+//Logical operators
+int gcpointer_equal(gcpointer_t* this, gcpointer_t* rhs)
+{
+	return this->ptr == rhs->ptr;
+}
+
+int gcpointer_not_equal(gcpointer_t* this, gcpointer_t* rhs)
+{
+	return this->ptr != rhs->ptr;
+}
+
+int gcpointer_null(gcpointer_t* this)
+{
+	return this->ptr == NULL;
+}
Index: src/examples/gc_no_raii/gcpointers.h
===================================================================
--- src/examples/gc_no_raii/gcpointers.h	(revision 15db1ab4e18373801ab9f3db0366d4b4a0ba7e95)
+++ src/examples/gc_no_raii/gcpointers.h	(revision 15db1ab4e18373801ab9f3db0366d4b4a0ba7e95)
@@ -0,0 +1,21 @@
+#pragma once
+
+struct gcpointer_t
+{
+	void* ptr;
+	struct gcpointer_t* next;
+};
+
+void gcpointer_ctor(gcpointer_t* this);
+// void gcpointer_ctor(gcpointer_t* ptr, (int)0);
+void gcpointer_ctor(gcpointer_t* this, void* address);
+void gcpointer_ctor(gcpointer_t* this, gcpointer_t* other);
+
+void gcpointer_dtor(gcpointer_t* this);
+
+gcpointer_t* gcpointer_assign(gcpointer_t* this, gcpointer_t* rhs);
+
+//Logical operators
+int gcpointer_equal(gcpointer_t* this, gcpointer_t* rhs);
+int gcpointer_not_equal(gcpointer_t* this, gcpointer_t* rhs);
+int gcpointer_null(gcpointer_t* this);
Index: src/examples/gc_no_raii/gctest.c
===================================================================
--- src/examples/gc_no_raii/gctest.c	(revision 15db1ab4e18373801ab9f3db0366d4b4a0ba7e95)
+++ src/examples/gc_no_raii/gctest.c	(revision 15db1ab4e18373801ab9f3db0366d4b4a0ba7e95)
@@ -0,0 +1,9 @@
+
+#include "gc.h"
+#include "fstream.h"
+
+int main() {
+	ofstream *sout = ofstream_stdout();
+	ifstream *sin = ifstream_stdin();
+	sout | "Bonjour au monde!\n";
+}
Index: src/examples/gc_no_raii/premake4.lua
===================================================================
--- src/examples/gc_no_raii/premake4.lua	(revision 15db1ab4e18373801ab9f3db0366d4b4a0ba7e95)
+++ src/examples/gc_no_raii/premake4.lua	(revision 15db1ab4e18373801ab9f3db0366d4b4a0ba7e95)
@@ -0,0 +1,48 @@
+#!lua
+
+-- Additional Linux libs: "X11", "Xxf86vm", "Xi", "Xrandr", "stdc++"
+
+includeDirList = {
+	"../"
+}
+
+libDirectories = {
+
+}
+
+
+if os.get() == "linux" then
+    linkLibs = {
+
+    }
+end
+
+premake.gcc.cc = "../cfa"
+premake.gcc.cxx = "../cfa"
+
+-- Build Options:
+buildOptions = {""}
+
+solution "CS488-Projects"
+    configurations { "Debug", "Release" }
+
+    project "GC_TEST"
+        kind "ConsoleApp"
+        language "C"
+        location "build"
+        objdir "build"
+        targetdir "."
+        buildoptions (buildOptions)
+        libdirs (libDirectories)
+        links (linkLibs)
+        linkoptions (linkOptionList)
+        includedirs (includeDirList)
+        files { "../fstream.c", "../iostream.c", "../iterator.c", "*.c" }
+
+    configuration "Debug"
+        defines { "DEBUG" }
+        flags { "Symbols" }
+
+    configuration "Release"
+        defines { "NDEBUG" }
+        flags { "Optimize" }
Index: src/examples/gc_no_raii/regen_makefile.sh
===================================================================
--- src/examples/gc_no_raii/regen_makefile.sh	(revision 15db1ab4e18373801ab9f3db0366d4b4a0ba7e95)
+++ src/examples/gc_no_raii/regen_makefile.sh	(revision 15db1ab4e18373801ab9f3db0366d4b4a0ba7e95)
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+premake4 clean
+premake4 gmake
+sed '/# GNU Make project makefile autogenerated by Premake/a CC = ..\/cfa\nCXX = ..\/cfa\n' build/Makefile > out
+mv out build/Makefile
Index: src/examples/gc_no_raii/tools.h
===================================================================
--- src/examples/gc_no_raii/tools.h	(revision 15db1ab4e18373801ab9f3db0366d4b4a0ba7e95)
+++ src/examples/gc_no_raii/tools.h	(revision 15db1ab4e18373801ab9f3db0366d4b4a0ba7e95)
@@ -0,0 +1,13 @@
+#pragma once
+
+#ifndef _DEBUG
+#define _DEBUG 0
+#endif
+
+#define DEF_bool 1
+#if DEF_bool
+#define bool _Bool
+#endif
+
+#include "tools/checks.hpp"
+#include "tools/print.hpp"
Index: src/examples/gc_no_raii/tools/checks.h
===================================================================
--- src/examples/gc_no_raii/tools/checks.h	(revision 15db1ab4e18373801ab9f3db0366d4b4a0ba7e95)
+++ src/examples/gc_no_raii/tools/checks.h	(revision 15db1ab4e18373801ab9f3db0366d4b4a0ba7e95)
@@ -0,0 +1,27 @@
+#pragma once
+
+#if _DEBUG
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#define check(x) do {\
+	if(!(x)) {\
+		printf("CHECK failed : %s at %s:%i\n", #x, __FILE__, __LINE__);\
+		abort();\
+	}}while(0)\
+
+#define checkf(x, ...) do {\
+	if(!(x)) {\
+		printf("CHECK failed : %s at %s:%i\n", #x, __FILE__, __LINE__);\
+		printf(__VA_ARGS__);\
+		abort();\
+	}}while(0)\
+
+#else
+
+#define check(x)
+
+#define checkf(x, format, ...)
+
+#endif //NO_CHECKS
Index: src/examples/gc_no_raii/tools/print.c
===================================================================
--- src/examples/gc_no_raii/tools/print.c	(revision 15db1ab4e18373801ab9f3db0366d4b4a0ba7e95)
+++ src/examples/gc_no_raii/tools/print.c	(revision 15db1ab4e18373801ab9f3db0366d4b4a0ba7e95)
@@ -0,0 +1,5 @@
+#include "tools.h"
+
+#if _DEBUG
+	ofstream *sout = ofstream_stdout();
+#endif
Index: src/examples/gc_no_raii/tools/print.h
===================================================================
--- src/examples/gc_no_raii/tools/print.h	(revision 15db1ab4e18373801ab9f3db0366d4b4a0ba7e95)
+++ src/examples/gc_no_raii/tools/print.h	(revision 15db1ab4e18373801ab9f3db0366d4b4a0ba7e95)
@@ -0,0 +1,15 @@
+#pragma once
+
+#if _DEBUG
+
+#include "fstream.h"
+
+extern ofstream *sout;
+
+#define DEBUG(x) sout | x | endl;
+
+#else
+
+#define DEBUG(x)
+
+#endif //NO_CHECKS
