diff -u -r -N FastPD_DemoVersion/block.h FastPD.src-patched/block.h
--- FastPD_DemoVersion/block.h	2003-08-12 00:32:42.000000000 +0200
+++ FastPD.src-patched/block.h	2013-04-29 10:28:13.000000000 +0200
@@ -89,8 +89,8 @@
 	deallocated only when the destructor is called.
 */
 
-#ifndef __BLOCK_H__
-#define __BLOCK_H__
+#ifndef __FAST_PD_BLOCK_H__
+#define __FAST_PD_BLOCK_H__
 
 #include <stdlib.h>
 
@@ -98,6 +98,8 @@
 /***********************************************************************/
 /***********************************************************************/
 
+namespace fastPDLib {
+
 template <class Type> class Block
 {
 public:
@@ -105,7 +107,7 @@
 	   (optionally) the pointer to the function which
 	   will be called if allocation failed; the message
 	   passed to this function is "Not enough memory!" */
-	Block(int size, void (*err_function)(char *) = NULL) { first = last = NULL; block_size = size; error_function = err_function; }
+	Block(int size, void (*err_function)(const char *) = NULL) { first = last = NULL; block_size = size; error_function = err_function; }
 
 	/* Destructor. Deallocates all items added so far */
 	~Block() { while (first) { block *next = first -> next; delete first; first = next; } }
@@ -192,7 +194,7 @@
 	block	*scan_current_block;
 	Type	*scan_current_data;
 
-	void	(*error_function)(char *);
+	void	(*error_function)(const char *);
 };
 
 /***********************************************************************/
@@ -206,7 +208,7 @@
 	   (optionally) the pointer to the function which
 	   will be called if allocation failed; the message
 	   passed to this function is "Not enough memory!" */
-	DBlock(int size, void (*err_function)(char *) = NULL) { first = NULL; first_free = NULL; block_size = size; error_function = err_function; }
+	DBlock(int size, void (*err_function)(const char *) = NULL) { first = NULL; first_free = NULL; block_size = size; error_function = err_function; }
 
 	/* Destructor. Deallocates all items added so far */
 	~DBlock() { while (first) { block *next = first -> next; delete first; first = next; } }
@@ -260,9 +262,10 @@
 	block		*first;
 	block_item	*first_free;
 
-	void	(*error_function)(char *);
+	void	(*error_function)(const char *);
 };
 
+}
 
 #endif
 
diff -u -r -N FastPD_DemoVersion/common.h FastPD.src-patched/common.h
--- FastPD_DemoVersion/common.h	2007-08-17 00:11:30.000000000 +0200
+++ FastPD.src-patched/common.h	2013-04-29 10:28:13.000000000 +0200
@@ -1,6 +1,10 @@
-#ifndef _COMMON_H_
-#define _COMMON_H_
+#ifndef _FAST_PD_COMMON_H_
+#define _FAST_PD_COMMON_H_
+
+namespace fastPDLib {
 
 typedef short TIME;
 
+}
+
 #endif
diff -u -r -N FastPD_DemoVersion/Fast_PD.cpp FastPD.src-patched/Fast_PD.cpp
--- FastPD_DemoVersion/Fast_PD.cpp	2009-01-14 13:50:32.000000000 +0100
+++ FastPD.src-patched/Fast_PD.cpp	2013-04-29 10:28:13.000000000 +0200
@@ -3,6 +3,8 @@
 #include <stdio.h>
 #include "Fast_PD.h"
 
+using namespace fastPDLib;
+
 typedef CV_Fast_PD::Real Real;
 
 /*
diff -u -r -N FastPD_DemoVersion/Fast_PD.h FastPD.src-patched/Fast_PD.h
--- FastPD_DemoVersion/Fast_PD.h	2009-02-24 16:10:46.000000000 +0100
+++ FastPD.src-patched/Fast_PD.h	2013-04-29 10:28:13.000000000 +0200
@@ -16,6 +16,10 @@
 #include "graph.h"
 #include "common.h"
 
+#include <inttypes.h>
+
+namespace fastPDLib {
+
 #define DIST(l0,l1)   (_dist[l1*_numlabels+l0])
 #define UPDATE_BALANCE_VAR0(y,d,h0,h1) { (y)+=(d); (h0)+=(d); (h1)-=d; }
 #define NEW_LABEL(n) ((n)->parent && !((n)->is_sink))
@@ -538,7 +542,7 @@
 					if ( _nodes[i].tr_cap )
 					{
 						//assert(  _nodes[i].tr_cap < 0 );
-						_nodes[i].parent  = TERMINAL;
+						_nodes[i].parent  = FAST_PD_TERMINAL;
 						_nodes[i].is_sink = 1;
 						_nodes[i].DIST = 1;
 					}
@@ -653,7 +657,7 @@
 				if ( nd->tr_cap > 0 )
 				{
 					nd -> is_sink = 0;
-					nd -> parent = TERMINAL;
+					nd -> parent = FAST_PD_TERMINAL;
 					nd -> DIST = 1;
 
 					_graph->set_active(nd);
@@ -664,7 +668,7 @@
 				else if (nd->tr_cap < 0)
 				{
 					nd -> is_sink = 1;
-					nd -> parent = TERMINAL;
+					nd -> parent = FAST_PD_TERMINAL;
 					nd -> DIST = 1;
 				}
 				else nd -> parent = NULL;
@@ -679,7 +683,7 @@
 				if ( nd->tr_cap > 0 )
 				{
 					nd -> is_sink = 0;
-					nd -> parent = TERMINAL;
+					nd -> parent = FAST_PD_TERMINAL;
 					nd -> DIST = 1;
 
 					_graph->set_active(nd);
@@ -690,7 +694,7 @@
 				else if (nd->tr_cap < 0)
 				{
 					nd -> is_sink = 1;
-					nd -> parent = TERMINAL;
+					nd -> parent = FAST_PD_TERMINAL;
 					nd -> DIST = 1;
 				}
 				else nd -> parent = NULL;
@@ -712,7 +716,7 @@
 			for( i = source_nodes_start1; i >= 0; )
 			{
 				Graph::node *n = &_nodes[i];
-				if ( n->parent == TERMINAL )
+				if ( n->parent == FAST_PD_TERMINAL )
 				{
 					Node_info *pinfo = &_pinfo[i];
 
@@ -779,7 +783,7 @@
 			for( i = 0; i < num_children; i++ )
 			{
 				Graph::node *n = _children[i];
-				unsigned int id  = ((unsigned int)n - (unsigned int)_nodes) / sizeof(Graph::node); 
+				uintptr_t  id  = (reinterpret_cast<uintptr_t >(n) - reinterpret_cast<uintptr_t >(_nodes)) / sizeof(Graph::node);
 				Node_info *pinfo = &_pinfo[id];
 
 				// If necessary, repair "loads" in case of non-metric
@@ -945,7 +949,7 @@
 		double MAX( double a, double b ) { return ( a >= b ? a : b ); }
 		double MIN( double a, double b ) { return ( a <= b ? a : b ); }
 
-		static void err_fun(char * msg)
+		static void err_fun(const char * msg)
 		{
 			printf("%s",msg);
 		}
@@ -1009,6 +1013,8 @@
         CV_Fast_PD operator=( const CV_Fast_PD &other );
 };
 
+}
+
 #endif /* __FAST_PD_H__ */
 
 //#############################################################################
diff -u -r -N FastPD_DemoVersion/graph.cpp FastPD.src-patched/graph.cpp
--- FastPD_DemoVersion/graph.cpp	2007-08-20 18:03:30.000000000 +0200
+++ FastPD.src-patched/graph.cpp	2013-04-29 10:28:13.000000000 +0200
@@ -4,7 +4,9 @@
 #include <stdio.h>
 #include "graph.h"
 
-Graph::Graph(node *nodes, arc *arcs, int num_nodes, void (*err_function)(char *))
+using namespace fastPDLib;
+
+Graph::Graph(node *nodes, arc *arcs, int num_nodes, void (*err_function)(const char *))
 {
 	error_function = err_function;
 	_nodes = nodes;
diff -u -r -N FastPD_DemoVersion/graph.h FastPD.src-patched/graph.h
--- FastPD_DemoVersion/graph.h	2009-02-24 16:10:08.000000000 +0100
+++ FastPD.src-patched/graph.h	2013-04-30 11:40:23.000000000 +0200
@@ -74,37 +74,42 @@
 	///////////////////////////////////////////////////
 */
 
-#ifndef __GRAPH_H__
-#define __GRAPH_H__
+#ifndef __FAST_PD_GRAPH_H__
+#define __FAST_PD_GRAPH_H__
 
 #include "block.h"
 #include "common.h"
 
+namespace fastPDLib {
+
 /*
 	Nodes, arcs and pointers to nodes are
 	added in blocks for memory and time efficiency.
 	Below are numbers of items in blocks
 */
-#define NODE_BLOCK_SIZE 512
-#define ARC_BLOCK_SIZE 1024
-#define NODEPTR_BLOCK_SIZE 128
+const unsigned int NODE_BLOCK_SIZE = 512;
+const unsigned int ARC_BLOCK_SIZE = 1024;
+const unsigned int NODEPTR_BLOCK_SIZE = 128;
+//#define NODE_BLOCK_SIZE 512
+//#define ARC_BLOCK_SIZE 1024
+//#define NODEPTR_BLOCK_SIZE 128
 
 /*
 	special constants for node->parent
 */
-#define TERMINAL ( (Graph::arc *) 1 )		/* to terminal */
-#define ORPHAN   ( (Graph::arc *) 2 )		/* orphan */
+#define FAST_PD_TERMINAL ( (Graph::arc *) 1 )		/* to terminal */
+#define FAST_PD_ORPHAN   ( (Graph::arc *) 2 )		/* orphan */
 
-#define INFINITE_D 1000000000		/* infinite distance to the terminal */
+#define FAST_PD_INFINITE_D 1000000000		/* infinite distance to the terminal */
 
 class Graph
 {
 public:
 
 #ifdef _MANY_LABELS_
-	typedef int Label;
+	typedef FASTPDLABELVALUE Label;
 #else
-	typedef unsigned char Label;
+	typedef FASTPDLABELVALUE Label;
 #endif
 
 	typedef enum
@@ -115,11 +120,11 @@
 
 	/* Type of edge weights.
 	   Can be changed to char, int, float, double, ... */
-	typedef int Real;
+	typedef FASTPDENERGYVALUE Real;
 	typedef Real captype;
 
 	/* Type of total flow */
-	typedef int flowtype;
+	typedef Real flowtype;
 
 	typedef void * node_id;
 
@@ -202,7 +207,7 @@
 	Block<arc>			*arc_block;
 	DBlock<nodeptr>		*nodeptr_block;
 
-	void	(*error_function)(char *);	/* this function is called if a error occurs,
+	void	(*error_function)(const char *);	/* this function is called if a error occurs,
 										   with a corresponding error message
 										   (or exit(1) is called if it's NULL) */
 
@@ -212,9 +217,9 @@
 	   function which will be called if an error occurs;
 	   an error message is passed to this function. If this
 	   argument is omitted, exit(1) will be called. */
-	Graph(node *nodes, arc *arcs, int num_nodes, void (*err_function)(char *) = NULL);
+	Graph(node *nodes, arc *arcs, int num_nodes, void (*err_function)(const char *) = NULL);
 
-	void Graph::reset_flow( void )
+	void reset_flow( void )
 	{
 		flow = 0;
 	}
@@ -249,7 +254,7 @@
 	is empty, it is replaced by the second queue
 	(and the second queue becomes empty).
 	*/
-	inline void Graph::set_active(node *i)
+	inline void set_active(node *i)
 	{
 		if (!i->next)
 		{
@@ -268,4 +273,6 @@
 	void process_sink_orphan(node *i);
 };
 
+}
+
 #endif
diff -u -r -N FastPD_DemoVersion/LinkedBlockList.cpp FastPD.src-patched/LinkedBlockList.cpp
--- FastPD_DemoVersion/LinkedBlockList.cpp	2005-07-21 09:02:30.000000000 +0200
+++ FastPD.src-patched/LinkedBlockList.cpp	2013-04-29 10:28:13.000000000 +0200
@@ -1,5 +1,7 @@
 #include "LinkedBlockList.h"
 
+using namespace fastPDLib;
+
 /*********************************************************************/
 
 void LinkedBlockList::addFront(ListType item) {
@@ -58,7 +60,7 @@
 		m_head = m_head->m_next;
 		delete tmp;
 	}
-};
+}
 
 /*********************************************************************/
 
diff -u -r -N FastPD_DemoVersion/LinkedBlockList.h FastPD.src-patched/LinkedBlockList.h
--- FastPD_DemoVersion/LinkedBlockList.h	2005-07-21 09:02:30.000000000 +0200
+++ FastPD.src-patched/LinkedBlockList.h	2013-04-29 10:28:13.000000000 +0200
@@ -6,14 +6,16 @@
 // For other graphs, it should be set to the average expected number of neighbors
 // Data in linked list for the neighborhood system is allocated in blocks of size GCLL_BLOCK_SIZE 
 
-#ifndef __LINKEDBLOCKLIST_H__
-#define __LINKEDBLOCKLIST_H__
+#ifndef __FAST_PD_LINKEDBLOCKLIST_H__
+#define __FAST_PD_LINKEDBLOCKLIST_H__
+
+namespace fastPDLib {
 
 #define GCLL_BLOCK_SIZE 4  
 // GCLL_BLOCKSIZE should "fit" into the type BlockType. That is 
 // if GCLL_BLOCKSIZE is larger than 255 but smaller than largest short integer
 // then  BlockType should be set to short
-typedef char BlockType;
+typedef unsigned char BlockType;
 
 //The type of data stored in the linked list
 typedef void * ListType;
@@ -46,5 +48,7 @@
 	LLBlock *m_cursor;
 };
 
+}
+
 #endif
 
diff -u -r -N FastPD_DemoVersion/maxflow.cpp FastPD.src-patched/maxflow.cpp
--- FastPD_DemoVersion/maxflow.cpp	2009-02-24 16:04:44.000000000 +0100
+++ FastPD.src-patched/maxflow.cpp	2013-04-29 10:28:13.000000000 +0200
@@ -4,6 +4,8 @@
 #include <stdio.h>
 #include "graph.h"
 
+using namespace fastPDLib;
+
 /*
 	special constants for node->parent
 */
@@ -63,7 +65,7 @@
 		{
 			/* i is connected to the source */
 			i -> is_sink = 0;
-			i -> parent = TERMINAL;
+			i -> parent = FAST_PD_TERMINAL;
 			set_active(i);
 			i -> TS = 0;
 			i -> DIST = 1;
@@ -72,7 +74,7 @@
 		{
 			/* i is connected to the sink */
 			i -> is_sink = 1;
-			i -> parent = TERMINAL;
+			i -> parent = FAST_PD_TERMINAL;
 			i -> TS = 0;
 			i -> DIST = 1;
 		}
@@ -100,7 +102,7 @@
 	for (i=middle_arc->sister->head; ; i=a->head)
 	{
 		a = i -> parent;
-		if (a == TERMINAL) break;
+		if (a == FAST_PD_TERMINAL) break;
 		if (bottleneck > a->sister->r_cap) bottleneck = a -> sister -> r_cap;
 	}
 	if (bottleneck > i->tr_cap) bottleneck = i -> tr_cap;
@@ -108,7 +110,7 @@
 	for (i=middle_arc->head; ; i=a->head)
 	{
 		a = i -> parent;
-		if (a == TERMINAL) break;
+		if (a == FAST_PD_TERMINAL) break;
 		if (bottleneck > a->r_cap) bottleneck = a -> r_cap;
 	}
 	if (bottleneck > - i->tr_cap) bottleneck = - i -> tr_cap;
@@ -121,13 +123,13 @@
 	for (i=middle_arc->sister->head; ; i=a->head)
 	{
 		a = i -> parent;
-		if (a == TERMINAL) break;
+		if (a == FAST_PD_TERMINAL) break;
 		a -> r_cap += bottleneck;
 		a -> sister -> r_cap -= bottleneck;
 		if (!a->sister->r_cap)
 		{
 			/* add i to the adoption list */
-			i -> parent = ORPHAN;
+			i -> parent = FAST_PD_ORPHAN;
 			np = nodeptr_block -> New();
 			np -> ptr = i;
 			np -> next = orphan_first;
@@ -138,7 +140,7 @@
 	if (!i->tr_cap)
 	{
 		/* add i to the adoption list */
-		i -> parent = ORPHAN;
+		i -> parent = FAST_PD_ORPHAN;
 		np = nodeptr_block -> New();
 		np -> ptr = i;
 		np -> next = orphan_first;
@@ -148,13 +150,13 @@
 	for (i=middle_arc->head; ; i=a->head)
 	{
 		a = i -> parent;
-		if (a == TERMINAL) break;
+		if (a == FAST_PD_TERMINAL) break;
 		a -> sister -> r_cap += bottleneck;
 		a -> r_cap -= bottleneck;
 		if (!a->r_cap)
 		{
 			/* add i to the adoption list */
-			i -> parent = ORPHAN;
+			i -> parent = FAST_PD_ORPHAN;
 			np = nodeptr_block -> New();
 			np -> ptr = i;
 			np -> next = orphan_first;
@@ -177,7 +179,7 @@
 	node *j;
 	arc *a0, *a0_min = NULL, *a;
 	nodeptr *np;
-	int d, d_min = INFINITE_D;
+	int d, d_min = FAST_PD_INFINITE_D;
 
 	/* trying to find a new parent */
 	for (a0=i->first; a0; a0=a0->next)
@@ -197,16 +199,16 @@
 				}
 				a = j -> parent;
 				d ++;
-				if (a==TERMINAL)
+				if (a==FAST_PD_TERMINAL)
 				{
 					j -> TS = TIME;
 					j -> DIST = 1;
 					break;
 				}
-				if (a==ORPHAN) { d = INFINITE_D; break; }
+				if (a==FAST_PD_ORPHAN) { d = FAST_PD_INFINITE_D; break; }
 				j = a -> head;
 			}
-			if (d<INFINITE_D) /* j originates from the source - done */
+			if (d<FAST_PD_INFINITE_D) /* j originates from the source - done */
 			{
 				if (d<d_min)
 				{
@@ -223,7 +225,7 @@
 		}
 	}
 
-	if (i->parent = a0_min)
+	if ((i->parent = a0_min))
 	{
 		i -> TS = TIME;
 		i -> DIST = d_min + 1;
@@ -240,10 +242,10 @@
 			if (!j->is_sink && (a=j->parent))
 			{
 				if (a0->sister->r_cap) set_active(j);
-				if (a!=TERMINAL && a!=ORPHAN && a->head==i)
+				if (a!=FAST_PD_TERMINAL && a!=FAST_PD_ORPHAN && a->head==i)
 				{
 					/* add j to the adoption list */
-					j -> parent = ORPHAN;
+					j -> parent = FAST_PD_ORPHAN;
 					np = nodeptr_block -> New();
 					np -> ptr = j;
 					if (orphan_last) orphan_last -> next = np;
@@ -261,7 +263,7 @@
 	node *j;
 	arc *a0, *a0_min = NULL, *a;
 	nodeptr *np;
-	int d, d_min = INFINITE_D;
+	int d, d_min = FAST_PD_INFINITE_D;
 
 	/* trying to find a new parent */
 	for (a0=i->first; a0; a0=a0->next)
@@ -281,16 +283,16 @@
 				}
 				a = j -> parent;
 				d ++;
-				if (a==TERMINAL)
+				if (a==FAST_PD_TERMINAL)
 				{
 					j -> TS = TIME;
 					j -> DIST = 1;
 					break;
 				}
-				if (a==ORPHAN) { d = INFINITE_D; break; }
+				if (a==FAST_PD_ORPHAN) { d = FAST_PD_INFINITE_D; break; }
 				j = a -> head;
 			}
-			if (d<INFINITE_D) /* j originates from the sink - done */
+			if (d<FAST_PD_INFINITE_D) /* j originates from the sink - done */
 			{
 				if (d<d_min)
 				{
@@ -307,7 +309,7 @@
 		}
 	}
 
-	if (i->parent = a0_min)
+	if ((i->parent = a0_min))
 	{
 		i -> TS = TIME;
 		i -> DIST = d_min + 1;
@@ -324,10 +326,10 @@
 			if (j->is_sink && (a=j->parent))
 			{
 				if (a0->r_cap) set_active(j);
-				if (a!=TERMINAL && a!=ORPHAN && a->head==i)
+				if (a!=FAST_PD_TERMINAL && a!=FAST_PD_ORPHAN && a->head==i)
 				{
 					/* add j to the adoption list */
-					j -> parent = ORPHAN;
+					j -> parent = FAST_PD_ORPHAN;
 					np = nodeptr_block -> New();
 					np -> ptr = j;
 					if (orphan_last) orphan_last -> next = np;
@@ -354,7 +356,7 @@
 
 	while ( 1 )
 	{
-		if (i=current_node)
+		if ((i=current_node))
 		{
 			i -> next = NULL; /* remove active flag */
 			if (!i->parent) i = NULL;
@@ -405,12 +407,12 @@
 			/* augmentation end */
 
 			/* adoption */
-			while (np=orphan_first)
+			while ((np=orphan_first))
 			{
 				np_next = np -> next;
 				np -> next = NULL;
 
-				while (np=orphan_first)
+				while ((np=orphan_first))
 				{
 					orphan_first = np -> next;
 					i = np -> ptr;
@@ -459,7 +461,7 @@
 		{
 			/* i is connected to the source */
 			i -> is_sink = 0;
-			i -> parent = TERMINAL;
+			i -> parent = FAST_PD_TERMINAL;
 			set_active(i);
 			i -> TS = 0;
 			i -> DIST = 1;
@@ -468,7 +470,7 @@
 		{
 			/* i is connected to the sink */
 			i -> is_sink = 1;
-			i -> parent = TERMINAL;
+			i -> parent = FAST_PD_TERMINAL;
 			set_active(i);
 			i -> TS = 0;
 			i -> DIST = 1;
@@ -498,7 +500,7 @@
 	for (i=middle_arc->sister->head; ; i=a->head)
 	{
 		a = i -> parent;
-		if (a == TERMINAL) break;
+		if (a == FAST_PD_TERMINAL) break;
 		if (bottleneck > a->sister->r_cap) bottleneck = a -> sister -> r_cap;
 	}
 	if (bottleneck > i->tr_cap) bottleneck = i -> tr_cap;
@@ -506,7 +508,7 @@
 	for (i=middle_arc->head; ; i=a->head)
 	{
 		a = i -> parent;
-		if (a == TERMINAL) break;
+		if (a == FAST_PD_TERMINAL) break;
 		if (bottleneck > a->r_cap) bottleneck = a -> r_cap;
 	}
 	if (bottleneck > - i->tr_cap) bottleneck = - i -> tr_cap;
@@ -519,13 +521,13 @@
 	for (i=middle_arc->sister->head; ; i=a->head)
 	{
 		a = i -> parent;
-		if (a == TERMINAL) break;
+		if (a == FAST_PD_TERMINAL) break;
 		a -> r_cap += bottleneck;
 		a -> sister -> r_cap -= bottleneck;
 		if (!a->sister->r_cap)
 		{
 			/* add i to the adoption list */
-			i -> parent = ORPHAN;
+			i -> parent = FAST_PD_ORPHAN;
 			np = nodeptr_block -> New();
 			np -> ptr = i;
 			np -> next = orphan_first;
@@ -536,7 +538,7 @@
 	if (!i->tr_cap)
 	{
 		/* add i to the adoption list */
-		i -> parent = ORPHAN;
+		i -> parent = FAST_PD_ORPHAN;
 		np = nodeptr_block -> New();
 		np -> ptr = i;
 		np -> next = orphan_first;
@@ -546,13 +548,13 @@
 	for (i=middle_arc->head; ; i=a->head)
 	{
 		a = i -> parent;
-		if (a == TERMINAL) break;
+		if (a == FAST_PD_TERMINAL) break;
 		a -> sister -> r_cap += bottleneck;
 		a -> r_cap -= bottleneck;
 		if (!a->r_cap)
 		{
 			/* add i to the adoption list */
-			i -> parent = ORPHAN;
+			i -> parent = FAST_PD_ORPHAN;
 			np = nodeptr_block -> New();
 			np -> ptr = i;
 			np -> next = orphan_first;
@@ -563,7 +565,7 @@
 	if (!i->tr_cap)
 	{
 		/* add i to the adoption list */
-		i -> parent = ORPHAN;
+		i -> parent = FAST_PD_ORPHAN;
 		np = nodeptr_block -> New();
 		np -> ptr = i;
 		np -> next = orphan_first;
@@ -587,7 +589,7 @@
 
 	while ( 1 )
 	{
-		if (i=current_node)
+		if ((i=current_node))
 		{
 			i -> next = NULL; /* remove active flag */
 			if (!i->parent) i = NULL;
@@ -663,12 +665,12 @@
 			/* augmentation end */
 
 			/* adoption */
-			while (np=orphan_first)
+			while ((np=orphan_first))
 			{
 				np_next = np -> next;
 				np -> next = NULL;
 
-				while (np=orphan_first)
+				while ((np=orphan_first))
 				{
 					orphan_first = np -> next;
 					i = np -> ptr;
