Index: src/Common/utility.h
===================================================================
--- src/Common/utility.h	(revision 99cad3aad093ce98f98e81cbb77ec56835527623)
+++ src/Common/utility.h	(revision 5b7a60c851aca1ac544ffd333591cd98ac25b716)
@@ -49,4 +49,12 @@
 }
 
+template< typename T, typename U >
+static inline T * maybeMoveBuild( const U *orig ) {
+	T* ret = maybeBuild<T>(orig);
+	delete orig;
+	return ret;
+}
+
+
 template< typename Input_iterator >
 void printEnums( Input_iterator begin, Input_iterator end, const char * const *name_array, std::ostream &os ) {
Index: src/Parser/ExpressionNode.cc
===================================================================
--- src/Parser/ExpressionNode.cc	(revision 99cad3aad093ce98f98e81cbb77ec56835527623)
+++ src/Parser/ExpressionNode.cc	(revision 5b7a60c851aca1ac544ffd333591cd98ac25b716)
@@ -167,5 +167,7 @@
 
 NameExpr * build_varref( const string *name, bool labelp ) {
-	return new NameExpr( *name, nullptr );
+	NameExpr *expr = new NameExpr( *name, nullptr );
+	delete name;
+	return expr;
 }
 
@@ -184,12 +186,12 @@
 	if ( dynamic_cast< VoidType * >( targetType ) ) {
 		delete targetType;
-		return new CastExpr( maybeBuild< Expression >(expr_node) );
+		return new CastExpr( maybeMoveBuild< Expression >(expr_node) );
 	} else {
-		return new CastExpr( maybeBuild< Expression >(expr_node), targetType );
+		return new CastExpr( maybeMoveBuild< Expression >(expr_node), targetType );
 	} // if
 }
 
 Expression *build_fieldSel( ExpressionNode *expr_node, NameExpr *member ) {
-	UntypedMemberExpr *ret = new UntypedMemberExpr( member->get_name(), maybeBuild< Expression >(expr_node) );
+	UntypedMemberExpr *ret = new UntypedMemberExpr( member->get_name(), maybeMoveBuild< Expression >(expr_node) );
 	delete member;
 	return ret;
@@ -198,5 +200,5 @@
 Expression *build_pfieldSel( ExpressionNode *expr_node, NameExpr *member ) {
 	UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) );
-	deref->get_args().push_back( maybeBuild< Expression >(expr_node) );
+	deref->get_args().push_back( maybeMoveBuild< Expression >(expr_node) );
 	UntypedMemberExpr *ret = new UntypedMemberExpr( member->get_name(), deref );
 	delete member;
@@ -205,8 +207,8 @@
 
 Expression *build_addressOf( ExpressionNode *expr_node ) {
-		return new AddressExpr( maybeBuild< Expression >(expr_node) );
+		return new AddressExpr( maybeMoveBuild< Expression >(expr_node) );
 }
 Expression *build_sizeOfexpr( ExpressionNode *expr_node ) {
-	return new SizeofExpr( maybeBuild< Expression >(expr_node) );
+	return new SizeofExpr( maybeMoveBuild< Expression >(expr_node) );
 }
 Expression *build_sizeOftype( DeclarationNode *decl_node ) {
@@ -214,5 +216,5 @@
 }
 Expression *build_alignOfexpr( ExpressionNode *expr_node ) {
-	return new AlignofExpr( maybeBuild< Expression >(expr_node) );
+	return new AlignofExpr( maybeMoveBuild< Expression >(expr_node) );
 }
 Expression *build_alignOftype( DeclarationNode *decl_node ) {
@@ -224,40 +226,40 @@
 
 Expression *build_and_or( ExpressionNode *expr_node1, ExpressionNode *expr_node2, bool kind ) {
-	return new LogicalExpr( notZeroExpr( maybeBuild< Expression >(expr_node1) ), notZeroExpr( maybeBuild< Expression >(expr_node2) ), kind );
+	return new LogicalExpr( notZeroExpr( maybeMoveBuild< Expression >(expr_node1) ), notZeroExpr( maybeMoveBuild< Expression >(expr_node2) ), kind );
 }
 
 Expression *build_unary_val( OperKinds op, ExpressionNode *expr_node ) {
 	std::list< Expression * > args;
-	args.push_back( maybeBuild< Expression >(expr_node) );
+	args.push_back( maybeMoveBuild< Expression >(expr_node) );
 	return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args );
 }
 Expression *build_unary_ptr( OperKinds op, ExpressionNode *expr_node ) {
 	std::list< Expression * > args;
-	args.push_back( new AddressExpr( maybeBuild< Expression >(expr_node) ) );
+	args.push_back( new AddressExpr( maybeMoveBuild< Expression >(expr_node) ) );
 	return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args );
 }
 Expression *build_binary_val( OperKinds op, ExpressionNode *expr_node1, ExpressionNode *expr_node2 ) {
 	std::list< Expression * > args;
-	args.push_back( maybeBuild< Expression >(expr_node1) );
-	args.push_back( maybeBuild< Expression >(expr_node2) );
+	args.push_back( maybeMoveBuild< Expression >(expr_node1) );
+	args.push_back( maybeMoveBuild< Expression >(expr_node2) );
 	return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args );
 }
 Expression *build_binary_ptr( OperKinds op, ExpressionNode *expr_node1, ExpressionNode *expr_node2 ) {
 	std::list< Expression * > args;
-	args.push_back( new AddressExpr( maybeBuild< Expression >(expr_node1) ) );
-	args.push_back( maybeBuild< Expression >(expr_node2) );
+	args.push_back( new AddressExpr( maybeMoveBuild< Expression >(expr_node1) ) );
+	args.push_back( maybeMoveBuild< Expression >(expr_node2) );
 	return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args );
 }
 
 Expression *build_cond( ExpressionNode *expr_node1, ExpressionNode *expr_node2, ExpressionNode *expr_node3 ) {
-	return new ConditionalExpr( notZeroExpr( maybeBuild< Expression >(expr_node1) ), maybeBuild< Expression >(expr_node2), maybeBuild< Expression >(expr_node3) );
+	return new ConditionalExpr( notZeroExpr( maybeMoveBuild< Expression >(expr_node1) ), maybeMoveBuild< Expression >(expr_node2), maybeMoveBuild< Expression >(expr_node3) );
 }
 
 Expression *build_comma( ExpressionNode *expr_node1, ExpressionNode *expr_node2 ) {
-	return new CommaExpr( maybeBuild< Expression >(expr_node1), maybeBuild< Expression >(expr_node2) );
+	return new CommaExpr( maybeMoveBuild< Expression >(expr_node1), maybeMoveBuild< Expression >(expr_node2) );
 }
 
 Expression *build_attrexpr( NameExpr *var, ExpressionNode * expr_node ) {
-	return new AttrExpr( var, maybeBuild< Expression >(expr_node) );
+	return new AttrExpr( var, maybeMoveBuild< Expression >(expr_node) );
 }
 Expression *build_attrtype( NameExpr *var, DeclarationNode * decl_node ) {
@@ -267,5 +269,5 @@
 Expression *build_tuple( ExpressionNode * expr_node ) {
 	TupleExpr *ret = new TupleExpr();
-	buildList( expr_node, ret->get_exprs() );
+	buildMoveList( expr_node, ret->get_exprs() );
 	return ret;
 }
@@ -273,21 +275,18 @@
 Expression *build_func( ExpressionNode * function, ExpressionNode * expr_node ) {
 	std::list< Expression * > args;
-
-	buildList( expr_node, args );
-	return new UntypedExpr( maybeBuild< Expression >(function), args, nullptr );
+	buildMoveList( expr_node, args );
+	return new UntypedExpr( maybeMoveBuild< Expression >(function), args, nullptr );
 }
 
 Expression *build_range( ExpressionNode * low, ExpressionNode *high ) {
-	Expression *low_cexpr = maybeBuild< Expression >( low );
-	Expression *high_cexpr = maybeBuild< Expression >( high );
-	return new RangeExpr( low_cexpr, high_cexpr );
+	return new RangeExpr( maybeMoveBuild< Expression >( low ), maybeMoveBuild< Expression >( high ) );
 }
 
 Expression *build_asmexpr( ExpressionNode *inout, ConstantExpr *constraint, ExpressionNode *operand ) {
-	return new AsmExpr( maybeBuild< Expression >( inout ), constraint, maybeBuild< Expression >(operand) );
+	return new AsmExpr( maybeMoveBuild< Expression >( inout ), constraint, maybeMoveBuild< Expression >(operand) );
 }
 
 Expression *build_valexpr( StatementNode *s ) {
-	return new UntypedValofExpr( maybeBuild< Statement >(s), nullptr );
+	return new UntypedValofExpr( maybeMoveBuild< Statement >(s), nullptr );
 }
 Expression *build_typevalue( DeclarationNode *decl ) {
@@ -298,12 +297,12 @@
 	Declaration * newDecl = maybeBuild< Declaration >(decl_node); // compound literal type
 	if ( DeclarationWithType * newDeclWithType = dynamic_cast< DeclarationWithType * >( newDecl ) ) { // non-sue compound-literal type
-		return new CompoundLiteralExpr( newDeclWithType->get_type(), maybeBuild< Initializer >(kids) );
+		return new CompoundLiteralExpr( newDeclWithType->get_type(), maybeMoveBuild< Initializer >(kids) );
 	// these types do not have associated type information
 	} else if ( StructDecl * newDeclStructDecl = dynamic_cast< StructDecl * >( newDecl )  ) {
-		return new CompoundLiteralExpr( new StructInstType( Type::Qualifiers(), newDeclStructDecl->get_name() ), maybeBuild< Initializer >(kids) );
+		return new CompoundLiteralExpr( new StructInstType( Type::Qualifiers(), newDeclStructDecl->get_name() ), maybeMoveBuild< Initializer >(kids) );
 	} else if ( UnionDecl * newDeclUnionDecl = dynamic_cast< UnionDecl * >( newDecl )  ) {
-		return new CompoundLiteralExpr( new UnionInstType( Type::Qualifiers(), newDeclUnionDecl->get_name() ), maybeBuild< Initializer >(kids) );
+		return new CompoundLiteralExpr( new UnionInstType( Type::Qualifiers(), newDeclUnionDecl->get_name() ), maybeMoveBuild< Initializer >(kids) );
 	} else if ( EnumDecl * newDeclEnumDecl = dynamic_cast< EnumDecl * >( newDecl )  ) {
-		return new CompoundLiteralExpr( new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ), maybeBuild< Initializer >(kids) );
+		return new CompoundLiteralExpr( new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ), maybeMoveBuild< Initializer >(kids) );
 	} else {
 		assert( false );
Index: src/Parser/ParseNode.h
===================================================================
--- src/Parser/ParseNode.h	(revision 99cad3aad093ce98f98e81cbb77ec56835527623)
+++ src/Parser/ParseNode.h	(revision 5b7a60c851aca1ac544ffd333591cd98ac25b716)
@@ -387,4 +387,11 @@
 void buildTypeList( const DeclarationNode *firstNode, std::list< Type * > &outputList );
 
+template< typename SynTreeType, typename NodeType >
+void buildMoveList( const NodeType *firstNode, std::list< SynTreeType * > &outputList ) {
+	buildList(firstNode, outputList);
+	delete firstNode;
+}
+
+
 #endif // PARSENODE_H
 
Index: src/Parser/StatementNode.cc
===================================================================
--- src/Parser/StatementNode.cc	(revision 99cad3aad093ce98f98e81cbb77ec56835527623)
+++ src/Parser/StatementNode.cc	(revision 5b7a60c851aca1ac544ffd333591cd98ac25b716)
@@ -62,5 +62,5 @@
 	StatementNode *node = dynamic_cast< StatementNode * >(prev);
 	std::list< Statement * > stmts;
-	buildList( stmt, stmts );
+	buildMoveList( stmt, stmts );
 	// splice any new Statements to end of current Statements
 	CaseStmt * caseStmt = dynamic_cast< CaseStmt * >(node->stmt);
@@ -70,5 +70,5 @@
 
 Statement *build_expr( ExpressionNode *ctl ) {
-	Expression *e = maybeBuild< Expression >( ctl );
+	Expression *e = maybeMoveBuild< Expression >( ctl );
 
 	if ( e )
@@ -81,5 +81,5 @@
 	Statement *thenb, *elseb = 0;
 	std::list< Statement * > branches;
-	buildList< Statement, StatementNode >( then_stmt, branches );
+	buildMoveList< Statement, StatementNode >( then_stmt, branches );
 	assert( branches.size() == 1 );
 	thenb = branches.front();
@@ -87,20 +87,20 @@
 	if ( else_stmt ) {
 		std::list< Statement * > branches;
-		buildList< Statement, StatementNode >( else_stmt, branches );
+		buildMoveList< Statement, StatementNode >( else_stmt, branches );
 		assert( branches.size() == 1 );
 		elseb = branches.front();
 	} // if
-	return new IfStmt( noLabels, notZeroExpr( maybeBuild< Expression >(ctl) ), thenb, elseb );
+	return new IfStmt( noLabels, notZeroExpr( maybeMoveBuild< Expression >(ctl) ), thenb, elseb );
 }
 
 Statement *build_switch( ExpressionNode *ctl, StatementNode *stmt ) {
 	std::list< Statement * > branches;
-	buildList< Statement, StatementNode >( stmt, branches );
+	buildMoveList< Statement, StatementNode >( stmt, branches );
 	assert( branches.size() >= 0 );						// size == 0 for switch (...) {}, i.e., no declaration or statements
-	return new SwitchStmt( noLabels, maybeBuild< Expression >(ctl), branches );
+	return new SwitchStmt( noLabels, maybeMoveBuild< Expression >(ctl), branches );
 }
 Statement *build_case( ExpressionNode *ctl ) {
 	std::list< Statement * > branches;
-	return new CaseStmt( noLabels, maybeBuild< Expression >(ctl), branches );
+	return new CaseStmt( noLabels, maybeMoveBuild< Expression >(ctl), branches );
 }
 Statement *build_default() {
@@ -111,26 +111,26 @@
 Statement *build_while( ExpressionNode *ctl, StatementNode *stmt, bool kind ) {
 	std::list< Statement * > branches;
-	buildList< Statement, StatementNode >( stmt, branches );
+	buildMoveList< Statement, StatementNode >( stmt, branches );
 	assert( branches.size() == 1 );
-	return new WhileStmt( noLabels, notZeroExpr( maybeBuild< Expression >(ctl) ), branches.front(), kind );
+	return new WhileStmt( noLabels, notZeroExpr( maybeMoveBuild< Expression >(ctl) ), branches.front(), kind );
 }
 
 Statement *build_for( ForCtl *forctl, StatementNode *stmt ) {
 	std::list< Statement * > branches;
-	buildList< Statement, StatementNode >( stmt, branches );
+	buildMoveList< Statement, StatementNode >( stmt, branches );
 	assert( branches.size() == 1 );
 
 	std::list< Statement * > init;
 	if ( forctl->init != 0 ) {
-		buildList( forctl->init, init );
+		buildMoveList( forctl->init, init );
 	} // if
 
 	Expression *cond = 0;
 	if ( forctl->condition != 0 )
-		cond = notZeroExpr( maybeBuild< Expression >(forctl->condition) );
+		cond = notZeroExpr( maybeMoveBuild< Expression >(forctl->condition) );
 
 	Expression *incr = 0;
 	if ( forctl->change != 0 )
-		incr = maybeBuild< Expression >(forctl->change);
+		incr = maybeMoveBuild< Expression >(forctl->change);
 
 	delete forctl;
@@ -142,15 +142,15 @@
 }
 Statement *build_computedgoto( ExpressionNode *ctl ) {
-	return new BranchStmt( noLabels, maybeBuild< Expression >(ctl), BranchStmt::Goto );
+	return new BranchStmt( noLabels, maybeMoveBuild< Expression >(ctl), BranchStmt::Goto );
 }
 
 Statement *build_return( ExpressionNode *ctl ) {
 	std::list< Expression * > exps;
-	buildList( ctl, exps );
+	buildMoveList( ctl, exps );
 	return new ReturnStmt( noLabels, exps.size() > 0 ? exps.back() : nullptr );
 }
 Statement *build_throw( ExpressionNode *ctl ) {
 	std::list< Expression * > exps;
-	buildList( ctl, exps );
+	buildMoveList( ctl, exps );
 	return new ReturnStmt( noLabels, exps.size() > 0 ? exps.back() : nullptr, true );
 }
@@ -158,19 +158,19 @@
 Statement *build_try( StatementNode *try_stmt, StatementNode *catch_stmt, StatementNode *finally_stmt ) {
 	std::list< Statement * > branches;
-	buildList< Statement, StatementNode >( catch_stmt, branches );
-	CompoundStmt *tryBlock = dynamic_cast< CompoundStmt * >(maybeBuild< Statement >(try_stmt));
+	buildMoveList< Statement, StatementNode >( catch_stmt, branches );
+	CompoundStmt *tryBlock = dynamic_cast< CompoundStmt * >(maybeMoveBuild< Statement >(try_stmt));
 	assert( tryBlock );
-	FinallyStmt *finallyBlock = dynamic_cast< FinallyStmt * >(maybeBuild< Statement >(finally_stmt) );
+	FinallyStmt *finallyBlock = dynamic_cast< FinallyStmt * >(maybeMoveBuild< Statement >(finally_stmt) );
 	return new TryStmt( noLabels, tryBlock, branches, finallyBlock );
 }
 Statement *build_catch( DeclarationNode *decl, StatementNode *stmt, bool catchAny ) {
 	std::list< Statement * > branches;
-	buildList< Statement, StatementNode >( stmt, branches );
+	buildMoveList< Statement, StatementNode >( stmt, branches );
 	assert( branches.size() == 1 );
-	return new CatchStmt( noLabels, maybeBuild< Declaration >(decl), branches.front(), catchAny );
+	return new CatchStmt( noLabels, maybeMoveBuild< Declaration >(decl), branches.front(), catchAny );
 }
 Statement *build_finally( StatementNode *stmt ) {
 	std::list< Statement * > branches;
-	buildList< Statement, StatementNode >( stmt, branches );
+	buildMoveList< Statement, StatementNode >( stmt, branches );
 	assert( branches.size() == 1 );
 	return new FinallyStmt( noLabels, dynamic_cast< CompoundStmt * >( branches.front() ) );
@@ -179,5 +179,5 @@
 Statement *build_compound( StatementNode *first ) {
 	CompoundStmt *cs = new CompoundStmt( noLabels );
-	buildList( first, cs->get_kids() );
+	buildMoveList( first, cs->get_kids() );
 	return cs;
 }
@@ -187,7 +187,7 @@
 	std::list< ConstantExpr * > clob;
 
-	buildList( output, out );
-	buildList( input, in );
-	buildList( clobber, clob );
+	buildMoveList( output, out );
+	buildMoveList( input, in );
+	buildMoveList( clobber, clob );
 	return new AsmStmt( noLabels, voltile, instruction, out, in, clob, gotolabels ? gotolabels->labels : noLabels );
 }
Index: src/examples/gc_no_raii/containers/vector
===================================================================
--- src/examples/gc_no_raii/containers/vector	(revision 5b7a60c851aca1ac544ffd333591cd98ac25b716)
+++ src/examples/gc_no_raii/containers/vector	(revision 5b7a60c851aca1ac544ffd333591cd98ac25b716)
@@ -0,0 +1,159 @@
+// 
+// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+// 
+// vector -- 
+// 
+// Author           : Thierry Delisle
+// Created On       : Tue Jul  5 18:00:07 2016
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Tue Jul  5 18:01:35 2016
+// Update Count     : 2
+// 
+
+#pragma once
+
+extern "C" {
+#include <stdbool.h>
+}
+
+#define DESTROY(x)
+
+//------------------------------------------------------------------------------
+//Declaration
+trait allocator_c(otype T, otype allocator_t)
+{
+	void ctor(allocator_t* const);
+	void dtor(allocator_t* const);
+	void realloc(allocator_t* const, size_t);
+	T* data(allocator_t* const);
+};
+
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+struct vector
+{
+	allocator_t storage;
+	size_t size;
+};
+
+//------------------------------------------------------------------------------
+//Initialization
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+void ctor(vector(T, allocator_t) *const this);
+
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+void dtor(vector(T, allocator_t) *const this);
+
+//------------------------------------------------------------------------------
+//Capacity
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+static inline bool empty(vector(T, allocator_t) *const this)
+{
+	return this->size == 0;
+}
+
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+static inline size_t size(vector(T, allocator_t) *const this)
+{
+	return this->size;
+}
+
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+static inline void reserve(vector(T, allocator_t) *const this, size_t size)
+{
+	realloc(&this->storage, this->size+1);
+}
+
+//------------------------------------------------------------------------------
+//Element access
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+static inline T at(vector(T, allocator_t) *const this, size_t index)
+{
+	return data(&this->storage)[index];
+}
+
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+static inline T ?[?](vector(T, allocator_t) *const this, size_t index)
+{
+	return data(&this->storage)[index];
+}
+
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+static inline T front(vector(T, allocator_t) *const this)
+{
+	return data(&this->storage)[0];
+}
+
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+static inline T back(vector(T, allocator_t) *const this)
+{
+	return data(&this->storage)[this->size - 1];
+}
+
+//------------------------------------------------------------------------------
+//Modifiers
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+void push_back(vector(T, allocator_t) *const this, T value);
+
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+void pop_back(vector(T, allocator_t) *const this);
+
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+void clear(vector(T, allocator_t) *const this);
+
+//------------------------------------------------------------------------------
+//Iterators
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+static inline T* begin(vector(T, allocator_t) *const this)
+{
+	return data(&this->storage);
+}
+
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+static inline const T* cbegin(const vector(T, allocator_t) *const this)
+{
+	return data(&this->storage);
+}
+
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+static inline T* end(vector(T, allocator_t) *const this)
+{
+	return data(&this->storage) + this->size;
+}
+
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+static inline const T* cend(const vector(T, allocator_t) *const this)
+{
+	return data(&this->storage) + this->size;
+}
+
+//------------------------------------------------------------------------------
+//Allocator
+forall(otype T)
+struct heap_allocator
+{
+	T* storage;
+	size_t capacity;
+};
+
+forall(otype T)
+void ctor(heap_allocator(T) *const this);
+
+forall(otype T)
+void dtor(heap_allocator(T) *const this);
+
+forall(otype T)
+void realloc(heap_allocator(T) *const this, size_t size);
+
+forall(otype T)
+static inline T* data(heap_allocator(T) *const this)
+{
+	return this->storage;
+}
+
+// Local Variables: //
+// mode: c //
+// tab-width: 4 //
+// End: //
Index: src/examples/gc_no_raii/containers/vector.c
===================================================================
--- src/examples/gc_no_raii/containers/vector.c	(revision 5b7a60c851aca1ac544ffd333591cd98ac25b716)
+++ src/examples/gc_no_raii/containers/vector.c	(revision 5b7a60c851aca1ac544ffd333591cd98ac25b716)
@@ -0,0 +1,92 @@
+// 
+// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+// 
+// vector.c -- 
+// 
+// Author           : Thierry Delisle
+// Created On       : Tue Jul  5 18:07:52 2016
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Tue Jul  5 18:08:31 2016
+// Update Count     : 2
+// 
+
+#include <containers/vector> 
+
+#include <stdlib>
+
+//------------------------------------------------------------------------------
+//Initialization
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+void ctor(vector(T, allocator_t) *const this)
+{
+	ctor(&this->storage);
+	this->size = 0;
+}
+
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+void dtor(vector(T, allocator_t) *const this)
+{
+	clear(this);
+	dtor(&this->storage);
+}
+
+//------------------------------------------------------------------------------
+//Modifiers
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+void push_back(vector(T, allocator_t) *const this, T value)
+{
+	realloc(&this->storage, this->size+1);
+	data(&this->storage)[this->size] = value;
+	this->size++;
+}
+
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+void pop_back(vector(T, allocator_t) *const this)
+{
+	this->size--;
+	DESTROY(data(&this->storage)[this->size]);
+}
+
+forall(otype T, otype allocator_t | allocator_c(T, allocator_t))
+void clear(vector(T, allocator_t) *const this)
+{
+	for(size_t i = 0; i < this->size; i++)
+	{
+		DESTROY(data(&this->storage)[this->size]);
+	}
+	this->size = 0;
+}
+
+//------------------------------------------------------------------------------
+//Allocator
+forall(otype T)
+void ctor(heap_allocator(T) *const this)
+{
+	this->storage = 0;
+	this->capacity = 0;
+}
+
+forall(otype T)
+void dtor(heap_allocator(T) *const this)
+{
+	free(this->storage);
+}
+
+forall(otype T)
+inline void realloc(heap_allocator(T) *const this, size_t size)
+{
+	enum { GROWTH_RATE = 2 };
+	if(size > this->capacity)
+	{
+		this->capacity = GROWTH_RATE * size;
+		this->storage = (T*)realloc((void*)this->storage, this->capacity * sizeof(T));
+	}
+}
+
+// Local Variables: //
+// mode: c //
+// tab-width: 4 //
+// End: //
Index: src/examples/gc_no_raii/premake4.lua
===================================================================
--- src/examples/gc_no_raii/premake4.lua	(revision 99cad3aad093ce98f98e81cbb77ec56835527623)
+++ src/examples/gc_no_raii/premake4.lua	(revision 5b7a60c851aca1ac544ffd333591cd98ac25b716)
@@ -6,4 +6,5 @@
 	"src/",
 	"../",
+	"containers/"
 }
 
@@ -48,5 +49,5 @@
 		linkoptions (linkOptionList)
 		includedirs (includeDirList)
-		files { "src/**.c" }
+		files { "src/**.c", "containers/**.c" }
 
 	configuration "debug"
Index: src/examples/gc_no_raii/src/gc.h
===================================================================
--- src/examples/gc_no_raii/src/gc.h	(revision 99cad3aad093ce98f98e81cbb77ec56835527623)
+++ src/examples/gc_no_raii/src/gc.h	(revision 5b7a60c851aca1ac544ffd333591cd98ac25b716)
@@ -4,18 +4,18 @@
 #include "internal/collector.h"
 
-forall(otype T)
-static inline gcpointer(T) gcmalloc()
-{
-    gcpointer(T) ptr = { gc_allocate(sizeof(T)) };
-    ptr{};
-    gc_conditional_collect();
-    return ptr;
-}
+// forall(otype T)
+// static inline gcpointer(T) gcmalloc()
+// {
+//     gcpointer(T) ptr = { gc_allocate(sizeof(T)) };
+//     ptr{};
+//     gc_conditional_collect();
+//     return ptr;
+// }
 
 forall(otype T)
 static inline void gcmalloc(gcpointer(T)* ptr)
 {
-	ptr{ gc_allocate(sizeof(T)) };
-      (*ptr){};
+	ptr { gc_allocate(sizeof(T)) };
+	get(ptr) {};
       gc_conditional_collect();
 }
Index: src/examples/gc_no_raii/src/gcpointers.c
===================================================================
--- src/examples/gc_no_raii/src/gcpointers.c	(revision 99cad3aad093ce98f98e81cbb77ec56835527623)
+++ src/examples/gc_no_raii/src/gcpointers.c	(revision 5b7a60c851aca1ac544ffd333591cd98ac25b716)
@@ -42,5 +42,5 @@
 }
 
-void gcpointer_ctor(gcpointer_t* this)
+void ?{}(gcpointer_t* this)
 {
 	this->ptr = (intptr_t)NULL;
@@ -48,5 +48,5 @@
 }
 
-void gcpointer_ctor(gcpointer_t* this, void* address)
+void ?{}(gcpointer_t* this, void* address)
 {
 	this->ptr = (intptr_t)address;
@@ -56,7 +56,7 @@
 }
 
-void gcpointer_ctor(gcpointer_t* this, gcpointer_t* other)
+void ?{}(gcpointer_t* this, gcpointer_t other)
 {
-	this->ptr = other->ptr;
+	this->ptr = other.ptr;
 	this->next = NULL;
 
@@ -64,5 +64,5 @@
 }
 
-void gcpointer_dtor(gcpointer_t* this)
+void ^?{}(gcpointer_t* this)
 {
 	unregister_ptr(this);
@@ -98,2 +98,30 @@
 	return this->ptr == (intptr_t)NULL;
 }
+
+forall(otype T) void ?{}(gcpointer(T)* this) {
+	(&this->internal) {};
+}
+
+forall(otype T) void ?{}(gcpointer(T)* this, void* address) {
+	(&this->internal) { address };
+}
+
+forall(otype T) void ?{}(gcpointer(T)* this, gcpointer(T)* other) {
+	(&this->internal) { other->internal };
+}
+
+forall(otype T) void ^?{}(gcpointer(T)* this) {
+	^?{}(&this->internal);
+}
+
+// forall(otype T) gcpointer(T) ?=?(gcpointer(T) this, gcpointer(T) rhs);
+//
+// forall(otype T) T *?(gcpointer(T) this);
+
+forall(otype T) T* get(gcpointer(T)* this) {
+	return (T*)this->internal.ptr;
+}
+//
+// //Logical operators
+// forall(otype T) int ?!=?(gcpointer(T) this, gcpointer(T) rhs);
+// forall(otype T) int ?==?(gcpointer(T) this, gcpointer(T) rhs);
Index: src/examples/gc_no_raii/src/gcpointers.h
===================================================================
--- src/examples/gc_no_raii/src/gcpointers.h	(revision 99cad3aad093ce98f98e81cbb77ec56835527623)
+++ src/examples/gc_no_raii/src/gcpointers.h	(revision 5b7a60c851aca1ac544ffd333591cd98ac25b716)
@@ -30,5 +30,4 @@
 forall(otype T) void ?{}(gcpointer(T)* this);
 forall(otype T) void ?{}(gcpointer(T)* this, void* address);
-forall(otype T) void ctor(gcpointer(T)* this, void* address);
 forall(otype T) void ?{}(gcpointer(T)* this, gcpointer(T)* other);
 forall(otype T) void ^?{}(gcpointer(T)* this);
@@ -37,4 +36,5 @@
 
 forall(otype T) T *?(gcpointer(T) this);
+forall(otype T) T* get(gcpointer(T)* this);
 
 //Logical operators
Index: src/examples/gc_no_raii/src/internal/collector.c
===================================================================
--- src/examples/gc_no_raii/src/internal/collector.c	(revision 99cad3aad093ce98f98e81cbb77ec56835527623)
+++ src/examples/gc_no_raii/src/internal/collector.c	(revision 5b7a60c851aca1ac544ffd333591cd98ac25b716)
@@ -8,4 +8,6 @@
 }
 #endif
+
+#include <fstream>
 
 #include "state.h"
@@ -36,5 +38,10 @@
 void* gc_allocate(size_t target_size)
 {
+	sout | "Allocating " | target_size | " bytes" | endl;
+
 	size_t size = gc_compute_size(target_size + sizeof(gc_object_header));
+
+	sout | "Object header size: " | sizeof(gc_object_header) | " bytes" | endl;
+	sout | "Actual allocation size: " | size | " bytes" | endl;
 
 	check(size < POOL_SIZE_BYTES);
Index: src/examples/gc_no_raii/src/internal/state.h
===================================================================
--- src/examples/gc_no_raii/src/internal/state.h	(revision 99cad3aad093ce98f98e81cbb77ec56835527623)
+++ src/examples/gc_no_raii/src/internal/state.h	(revision 5b7a60c851aca1ac544ffd333591cd98ac25b716)
@@ -9,4 +9,5 @@
 }
 #endif
+#include <fstream>
 #include <vector>
 
@@ -37,4 +38,5 @@
 static inline bool gc_needs_collect(gc_state* state)
 {
+	sout | "Used Space: " | state->used_space | " bytes" | endl;
 	return state->used_space * 2 > state->total_space;
 }
Index: src/examples/gc_no_raii/test/gctest.c
===================================================================
--- src/examples/gc_no_raii/test/gctest.c	(revision 99cad3aad093ce98f98e81cbb77ec56835527623)
+++ src/examples/gc_no_raii/test/gctest.c	(revision 5b7a60c851aca1ac544ffd333591cd98ac25b716)
@@ -2,4 +2,5 @@
 
 #include "gc.h"
+#include "internal/collector.h"
 
 #warning default test
@@ -8,7 +9,17 @@
 	sout | "Bonjour au monde!\n";
 
-	for(int i = 0; i < 1000000; i++) {
-		gcpointer(int) anInt;
-		gcmalloc(&anInt);
+	gcpointer(int) theInt;
+	gcmalloc(&theInt);
+
+	for(int i = 0; i < 10; i++) {
+		int a;
+		{
+			gcpointer(int) anInt;
+			gcmalloc(&anInt);
+		}
+		int p;
 	}
+
+	gc_collect(gc_get_state());
+	gc_conditional_collect();
 }
