Index: src/examples/wrapper/src/main.c
===================================================================
--- src/examples/wrapper/src/main.c	(revision 58440cef37185b562c617a2d73115453a66fcb5d)
+++ src/examples/wrapper/src/main.c	(revision 13488cad2ace2998cad1818506b8fedc6f30496c)
@@ -3,7 +3,5 @@
 int main(int argc, char const *argv[])
 {
-	content_t c;
-
-	content_t* cp = (content_t*)malloc();
+	wrapper_t p;
 	return 0;
 }
Index: src/examples/wrapper/src/pointer.h
===================================================================
--- src/examples/wrapper/src/pointer.h	(revision 58440cef37185b562c617a2d73115453a66fcb5d)
+++ src/examples/wrapper/src/pointer.h	(revision 13488cad2ace2998cad1818506b8fedc6f30496c)
@@ -3,5 +3,26 @@
 #include <fstream>
 #include <stddef.h>
-#include <stdlib.h>
+#include <stdlib>
+
+//==============================================================================
+// type safe malloc / free
+
+forall(otype T)
+T* new()
+{
+	T* p = malloc();
+	p{};
+	return p;
+}
+
+forall(otype T)
+void delete(T* p)
+{
+	^p{};
+	free(p);
+}
+
+//==============================================================================
+// ref counter content
 
 struct content_t
@@ -17,4 +38,10 @@
 }
 
+void ?{}(content_t* this)
+{
+	sout | "Constructing content" | endl;
+	this->count = 0;
+}
+
 void ^?{}(content_t* this)
 {
@@ -22,23 +49,47 @@
 }
 
-// struct wrapper_t
-// {
-// 	content_t* ptr;
-// };
-//
-// void ?{}(wrapper_t* this)
-// {
-// 	//content_t** cp = &this->ptr;
-// 	//*cp = malloc();
-// 	this->ptr->count++;
-// 	sout | "Constructing ref pointer" | endl;
-// 	sout | "Reference is " | this->ptr->count | endl;
-// }
-//
-// void ^?{}(wrapper_t* this)
-// {
-// 	this->ptr->count--;
-// 	if(!this->ptr->count) free(this->ptr);
-// 	sout | "Destroying ref pointer" | endl;
-// 	sout | "Reference is " | this->ptr->count | endl;
-// }
+//==============================================================================
+// ref counter wrapper
+
+struct wrapper_t
+{
+	content_t* ptr;
+};
+
+wrapper_t wrap(int val)
+{
+	wrapper_t w;
+	content_t* c = malloc;
+	c{};
+	c->value = val;
+	reset(&w, c);
+	return w;
+}
+
+void ?{}(wrapper_t* this)
+{
+	this->ptr = new();
+	this->ptr->count++;
+	sout | "Constructing empty ref pointer" | endl;
+}
+
+void ^?{}(wrapper_t* this)
+{
+	{
+		this->ptr->count--;
+		if(!this->ptr->count) delete(this->ptr);
+		sout | "Destroying ref pointer" | endl;
+		sout | "Reference is " | this->ptr->count | endl;
+	}
+	else
+	{
+		sout | "Destroying empty ref pointer" | endl;
+	}
+}
+
+void set(wrapper_t* this, content_t* c)
+{
+	this->ptr = c;
+	sout | "Setting ref pointer" | endl;
+	sout | "Reference is " | this->ptr->count | endl;
+}
