[cig-commits] r6082 - in long/3D/Gale/trunk/src/StGermain: . Base/Container/src Base/Container/tests Discretisation/Mesh/src

walter at geodynamics.org walter at geodynamics.org
Fri Feb 23 10:02:10 PST 2007


Author: walter
Date: 2007-02-23 10:02:07 -0800 (Fri, 23 Feb 2007)
New Revision: 6082

Modified:
   long/3D/Gale/trunk/src/StGermain/
   long/3D/Gale/trunk/src/StGermain/Base/Container/src/RangeSet.c
   long/3D/Gale/trunk/src/StGermain/Base/Container/src/RangeSet.h
   long/3D/Gale/trunk/src/StGermain/Base/Container/src/types.h
   long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testRangeSet.c
   long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Decomp.c
   long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/DecompTransfer.c
   long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Decomp_Sync.c
   long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Decomposer.c
   long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshTopology.c
Log:
 r3333 at earth (orig r4002):  LukeHodkinson | 2007-02-11 18:45:40 -0800
 First part of a fix to the range set class improving
 scalability.  This commit causes an assertion in some
 runs, I'm committing it in order to use valgrind on 
 another machine to find the problem.
 



Property changes on: long/3D/Gale/trunk/src/StGermain
___________________________________________________________________
Name: svk:merge
   - 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:3196
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/branches/decomp3d/StGermain:4000
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3899
   + 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:3196
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/branches/decomp3d/StGermain:4002
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3899

Modified: long/3D/Gale/trunk/src/StGermain/Base/Container/src/RangeSet.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/Container/src/RangeSet.c	2007-02-23 18:02:03 UTC (rev 6081)
+++ long/3D/Gale/trunk/src/StGermain/Base/Container/src/RangeSet.c	2007-02-23 18:02:07 UTC (rev 6082)
@@ -77,8 +77,8 @@
 	assert( self );
 
 	self->nInds = 0;
-	self->nRanges = 0;
-	self->ranges = NULL;
+	self->btree = BTree_New( RangeSet_DataCompare, RangeSet_DataCopy, RangeSet_DataDelete, NULL, 
+				 BTREE_NO_DUPLICATES );
 }
 
 
@@ -92,6 +92,7 @@
 	assert( self );
 
 	RangeSet_Destruct( self );
+	FreeObject( self->btree );
 
 	/* Delete the parent. */
 	_Stg_Class_Delete( self );
@@ -112,14 +113,13 @@
 void* _RangeSet_Copy( void* rangeSet, void* destProc_I, Bool deep, Name nameExt, PtrMap* ptrMap ) {
 	RangeSet*	self = (RangeSet*)rangeSet;
 	RangeSet*	newRangeSet;
+	unsigned	nInds, *inds;
 
+	inds = NULL;
+	RangeSet_GetIndices( self, &nInds, &inds );
 	newRangeSet = RangeSet_New();
-	newRangeSet->nInds = self->nInds;
-	newRangeSet->nRanges = self->nRanges;
-	if( self->nRanges ) {
-		newRangeSet->ranges = Memory_Alloc_Array( RangeSet_Range, self->nRanges, "RangeSet::ranges" );
-		memcpy( newRangeSet->ranges, self->ranges, self->nRanges * sizeof(RangeSet_Range) );
-	}
+	RangeSet_SetIndices( self, nInds, inds );
+	FreeArray( inds );
 
 	return (void*)newRangeSet;
 }
@@ -146,52 +146,41 @@
 	qsort( tmpInds, nInds, sizeof(unsigned), RangeSet_SortCmp );
 
 	while( curInd < nInds ) {
-		RangeSet_Range*	range;
+		RangeSet_Range	rng;
 
-		if( !self->ranges ) {
-			self->ranges = Memory_Alloc_Array( RangeSet_Range, ++self->nRanges, "RangeSet::ranges" );
-		}
-		else {
-			self->ranges = Memory_Realloc_Array( self->ranges, RangeSet_Range, ++self->nRanges );
-		}
-
-		range = self->ranges + self->nRanges - 1;
-
-		range->begin = tmpInds[curInd++];
+		rng.begin = tmpInds[curInd++];
 		while( curInd < nInds && tmpInds[curInd] == tmpInds[curInd - 1] ) {
 			curInd++;
 			self->nInds--;
 		}
-
 		if( curInd == nInds ) {
-			range->end = range->begin + 1;
-			range->step = 1;
+			rng.end = rng.begin + 1;
+			rng.step = 1;
 			break;
 		}
 
-		range->end = tmpInds[curInd++];
-		while( curInd < nInds && tmpInds[curInd] == range->end ) {
+		rng.end = tmpInds[curInd++];
+		while( curInd < nInds && tmpInds[curInd] == rng.end ) {
 			curInd++;
 			self->nInds--;
 		}
+		rng.step = rng.end - rng.begin;
 
-		range->step = range->end - range->begin;
-
-		while( curInd < nInds && tmpInds[curInd] - range->end == range->step ) {
-			range->end = tmpInds[curInd++];
-			while( curInd < nInds && tmpInds[curInd] == range->end ) {
+		while( curInd < nInds && tmpInds[curInd] - rng.end == rng.step ) {
+			rng.end = tmpInds[curInd++];
+			while( curInd < nInds && tmpInds[curInd] == rng.end ) {
 				curInd++;
 				self->nInds--;
 			}
 		}
+		rng.end++;
 
-		range->end++;
+		BTree_InsertNode( self->btree, &rng, sizeof(RangeSet_Range) );
 	}
 
 	FreeArray( tmpInds );
 }
 
-
 void RangeSet_AddIndices( void* rangeSet, unsigned nInds, unsigned* inds ) {
 	RangeSet*	self = (RangeSet*)rangeSet;
 	RangeSet*	tmpSet;
@@ -203,22 +192,20 @@
 	RangeSet_Union( self, tmpSet );
 }
 
-
 void RangeSet_SetRange( void* rangeSet, unsigned begin, unsigned end, unsigned step ) {
 	RangeSet*	self = (RangeSet*)rangeSet;
+	RangeSet_Range	rng;
 
 	assert( self );
 
 	RangeSet_Destruct( self );
 	self->nInds = (end - begin) / step;
-	self->nRanges = 1;
-	self->ranges = AllocArray( RangeSet_Range, 1 );
-	self->ranges[0].begin = begin;
-	self->ranges[0].end = end;
-	self->ranges[0].step = step;
+	rng.begin = begin;
+	rng.end = end;
+	rng.step = step;
+	BTree_InsertNode( self->btree, &rng, sizeof(RangeSet_Range) );
 }
 
-
 void RangeSet_Clear( void* rangeSet ) {
 	RangeSet*	self = (RangeSet*)rangeSet;
 
@@ -227,95 +214,165 @@
 	RangeSet_Destruct( self );
 }
 
+void RangeSet_GetIndices( void* rangeSet, unsigned* nInds, unsigned** inds ) {
+	RangeSet*		self = (RangeSet*)rangeSet;
+	RangeSet_ParseStruct	parse;
 
-void RangeSet_Union( void* rangeSet, RangeSet* rSet ) {
+	assert( self );
+
+	parse.nInds = 0;
+	parse.inds = (*inds) ? *inds : AllocArray( unsigned, self->nInds );
+	BTree_ParseTree( self->btree, RangeSet_GetIndicesParse, &parse );
+
+	*nInds = parse.nInds;
+	*inds = parse.inds;
+
+	/* Sanity check. */
+	assert( *nInds == self->nInds );
+}
+
+unsigned RangeSet_GetSize( void* rangeSet ) {
 	RangeSet*	self = (RangeSet*)rangeSet;
-	unsigned	maxInds;
-	unsigned	nInds = 0;
-	unsigned*	inds;
-	unsigned	r_i;
 
 	assert( self );
-	assert( rSet );
 
-	maxInds = rSet->nInds + self->nInds;
-	inds = Memory_Alloc_Array_Unnamed( unsigned, maxInds );
-	for( r_i = 0; r_i < self->nRanges; r_i++ ) {
-		RangeSet_Range*	range = self->ranges + r_i;
-		unsigned	ind_i;
+	return self->nInds;
+}
 
-		for( ind_i = range->begin; ind_i < range->end; ind_i += range->step )
-			inds[nInds++] = ind_i;
-	}
-	for( r_i = 0; r_i < rSet->nRanges; r_i++ ) {
-		RangeSet_Range*	range = rSet->ranges + r_i;
-		unsigned	ind_i;
+unsigned RangeSet_GetNumRanges( void* rangeSet ) {
+	RangeSet*	self = (RangeSet*)rangeSet;
 
-		for( ind_i = range->begin; ind_i < range->end; ind_i += range->step )
-			inds[nInds++] = ind_i;
-	}
+	assert( self );
+	assert( self->btree );
 
-	RangeSet_SetIndices( self, nInds, inds );
-	FreeArray( inds );
+	return self->btree->nodeCount;
 }
 
+RangeSet_Range* RangeSet_GetRange( void* rangeSet, unsigned index ) {
+	RangeSet*		self = (RangeSet*)rangeSet;
+	RangeSet_ParseStruct	parse;
 
-void RangeSet_Intersection( void* rangeSet, RangeSet* rSet ) {
+	assert( self );
+	assert( self->btree );
+	assert( index < self->btree->nodeCount );
+
+	parse.nInds = index;
+	parse.curInd = 0;
+	BTree_ParseTree( self->btree, RangeSet_GetRangeParse, &parse );
+
+	return parse.range;
+}
+
+Bool RangeSet_HasIndex( void* rangeSet, unsigned index ) {
 	RangeSet*	self = (RangeSet*)rangeSet;
-	unsigned	maxInds;
-	unsigned	nInds = 0;
-	unsigned*	inds;
-	unsigned	r_i;
+	RangeSet_Range	rng;
+	BTreeNode*	node;
 
 	assert( self );
-	assert( rSet );
 
-	maxInds = (rSet->nInds > self->nInds) ? rSet->nInds : self->nInds;
-	inds = Memory_Alloc_Array_Unnamed( unsigned, maxInds );
+	rng.begin = index;
+	rng.end = index + 1;
+	rng.step = 1;
+	node = BTree_FindNode( self->btree, &rng );
 
-	for( r_i = 0; r_i < self->nRanges; r_i++ ) {
-		RangeSet_Range*	range = self->ranges + r_i;
-		unsigned	ind_i;
+	if( node )
+		return RangeSet_Range_HasIndex( node->data, index );
+	else
+		return False;
+}
 
-		for( ind_i = range->begin; ind_i < range->end; ind_i += range->step ) {
-			if( RangeSet_HasIndex( rSet, ind_i ) )
-				inds[nInds++] = ind_i;
-		}
-	}
+void RangeSet_Union( void* rangeSet, RangeSet* rSet ) {
+	RangeSet*	self = (RangeSet*)rangeSet;
+	unsigned	nInds, *inds, *tmpInds;
 
-	RangeSet_SetIndices( self, nInds, inds );
+	assert( self );
+	assert( rSet );
+
+	inds = AllocArray( unsigned, rSet->nInds + self->nInds );
+	RangeSet_GetIndices( self, &nInds, &inds );
+	assert( nInds == self->nInds );
+	tmpInds = inds + self->nInds;
+	RangeSet_GetIndices( rSet, &nInds, &tmpInds );
+
+	RangeSet_SetIndices( self, rSet->nInds + self->nInds, inds );
 	FreeArray( inds );
 }
 
+void RangeSet_Intersection( void* rangeSet, RangeSet* rSet ) {
+	RangeSet*		self = (RangeSet*)rangeSet;
+	RangeSet_ParseStruct	parse;
 
+	assert( self );
+	assert( rSet );
+
+	parse.operand = rSet;
+	parse.nInds = 0;
+	parse.inds = AllocArray( unsigned, (self->nInds > rSet->nInds) ? self->nInds : rSet->nInds );
+	BTree_ParseTree( self->btree, RangeSet_IntersectionParse, &parse );
+
+	RangeSet_SetIndices( self, parse.nInds, parse.inds );
+	FreeArray( parse.inds );
+
+#if 0
+	RangeSet*		self = (RangeSet*)rangeSet;
+	RangeSet_ParseStruct	parse;
+
+	assert( self );
+	assert( rSet );
+
+	parse.self = self;
+	parse.operand = rSet;
+	parse.range = NULL;
+	parse.newTree = BTree_New( RangeSet_DataCompare, RangeSet_DataCopy, RangeSet_DataDelete, NULL, 
+					 BTREE_NO_DUPLICATES );
+	parse.nInds = 0;
+	BTree_ParseTree( self->btree, RangeSet_IntersectionParse, &parse );
+
+	FreeObject( self->btree );
+	self->btree = parse.newTree;
+	self->nInds = parse.nInds;
+#endif
+}
+
 void RangeSet_Subtraction( void* rangeSet, RangeSet* rSet ) {
-	RangeSet*	self = (RangeSet*)rangeSet;
-	unsigned	maxInds;
-	unsigned	nInds = 0;
-	unsigned*	inds;
-	unsigned	r_i;
+	RangeSet*		self = (RangeSet*)rangeSet;
+	RangeSet_ParseStruct	parse;
 
 	assert( self );
 	assert( rSet );
 
-	maxInds = self->nInds;
-	inds = Memory_Alloc_Array_Unnamed( unsigned, maxInds );
+	parse.operand = rSet;
+	parse.nInds = 0;
+	parse.inds = AllocArray( unsigned, self->nInds );
+	BTree_ParseTree( self->btree, RangeSet_SubtractionParse, &parse );
 
-	for( r_i = 0; r_i < self->nRanges; r_i++ ) {
-		RangeSet_Range*	range = self->ranges + r_i;
-		unsigned	ind_i;
+	RangeSet_SetIndices( self, parse.nInds, parse.inds );
+	FreeArray( parse.inds );
+}
 
-		for( ind_i = range->begin; ind_i < range->end; ind_i += range->step ) {
-			if( !RangeSet_HasIndex( rSet, ind_i ) )
-				inds[nInds++] = ind_i;
-		}
+void RangeSet_Pickle( void* rangeSet, unsigned* nBytes, Stg_Byte** bytes ) {
+	RangeSet*	self = (RangeSet*)rangeSet;
+
+	assert( self );
+	assert( nBytes );
+	assert( bytes );
+
+	if( self->nInds ) {
+		RangeSet_ParseStruct	parse;
+
+		*nBytes = sizeof(unsigned) + self->btree->nodeCount * sizeof(RangeSet_Range);
+		*bytes = AllocArray( Stg_Byte, *nBytes );
+		((unsigned*)*bytes)[0] = self->nInds;
+		parse.bytes = *bytes;
+		parse.curInd = 0;
+		BTree_ParseTree( self->btree, RangeSet_PickleParse, &parse );
 	}
-
-	RangeSet_SetIndices( self, nInds, inds );
-	FreeArray( inds );
+	else {
+		*nBytes = 0;
+		*bytes = NULL;
+	}
 }
 
-
 void RangeSet_Unpickle( void* rangeSet, unsigned nBytes, Stg_Byte* bytes ) {
 	RangeSet*	self = (RangeSet*)rangeSet;
 
@@ -328,124 +385,226 @@
 	if( nBytes ) {
 		self->nInds = ((unsigned*)bytes)[0];
 		if( self->nInds ) {
-			self->nRanges = (nBytes - sizeof(unsigned)) / sizeof(RangeSet_Range);
-			self->ranges = Memory_Alloc_Array( RangeSet_Range, self->nRanges, "RangeSet::ranges" );
-			memcpy( self->ranges, bytes + sizeof(unsigned), nBytes - sizeof(unsigned) );
+			unsigned	nRngs;
+			RangeSet_Range*	rng;
+			unsigned	r_i;
+
+			nRngs = (nBytes - sizeof(unsigned)) / sizeof(RangeSet_Range);
+			for( r_i = 0; r_i < nRngs; r_i++ ) {
+				rng = (RangeSet_Range*)(bytes + sizeof(unsigned) + r_i * sizeof(RangeSet_Range));
+				BTree_InsertNode( self->btree, rng, sizeof(RangeSet_Range) );
+			}
 		}
 	}
 }
 
+unsigned RangeSet_Range_GetNumIndices( RangeSet_Range* self ) {
+	unsigned	w;
 
-void RangeSet_GetIndices( void* rangeSet, unsigned* nInds, unsigned** inds ) {
-	RangeSet*	self = (RangeSet*)rangeSet;
-	unsigned	r_i;
+	assert( self );
 
+	w = self->end - self->begin;
+	return w / self->step + ((w % self->step) ? 1 : 0);
+}
+
+void RangeSet_Range_GetIndices( RangeSet_Range* self, unsigned* nInds, unsigned** inds ) {
+	unsigned	ind_i;
+
 	assert( self );
 
+	if( !(*inds) )
+		*inds = AllocArray( unsigned, RangeSet_Range_GetNumIndices( self ) );
+
 	*nInds = 0;
-	if( self->nInds )
-		*inds = Memory_Alloc_Array_Unnamed( unsigned, self->nInds );
-	else
-		*inds = NULL;
+	for( ind_i = self->begin; ind_i < self->end; ind_i += self->step )
+		(*inds)[(*nInds)++] = ind_i;
+}
 
-	for( r_i = 0; r_i < self->nRanges; r_i++ ) {
-		RangeSet_Range*	range = self->ranges + r_i;
-		unsigned	ind_i;
+Bool RangeSet_Range_HasIndex( RangeSet_Range* self, unsigned index ) {
+	assert( self );
+	assert( self->step > 0 );
 
-		for( ind_i = range->begin; ind_i < range->end; ind_i += range->step )
-			(*inds)[(*nInds)++] = ind_i;
-	}
+	if( index < self->begin || index > self->end )
+		return False;
 
-	/* Sanity check. */
-	assert( *nInds == self->nInds );
+	return ((index - self->begin) % self->step) ? False : True;
 }
 
+void RangeSet_Range_Intersection( RangeSet_Range* left, RangeSet_Range* right, RangeSet_Range* result ) {
+	unsigned	a, b, t;
+	unsigned	ind_i;
 
-Bool RangeSet_HasIndex( void* rangeSet, unsigned ind ) {
-	RangeSet*	self = (RangeSet*)rangeSet;
-	unsigned	r_i;
+	assert( left );
+	assert( right );
+	assert( result );
 
-	assert( self );
-
-	for( r_i = 0; r_i < self->nRanges; r_i++ ) {
-		RangeSet_Range*	range = self->ranges + r_i;
-
-		if( ind >= range->begin && ind < range->end ) {
-			if( !((ind - range->begin) % range->step) )
-				return True;
-		}
-		else if( ind < range->begin )
+	/* Find start point. */
+	for( ind_i = right->begin; ind_i < right->end; ind_i += right->step ) {
+		if( RangeSet_Range_HasIndex( left, ind_i ) )
 			break;
 	}
+	if( ind_i >= right->end ) {
+		result->begin = 0;
+		result->end = 0;
+		result->step = 1;
+	}
+	else
+		result->begin = ind_i;
 
-	return False;
+	/* Calculate step size using Euclid's theorem. */
+	a = left->step;
+	b = right->step;
+	while( b != 0 ) {
+		t = b;
+		b = a % b;
+		a = t;
+	}
+	result->step = a;
+
+	/* Calculate end point. */
+	t = (left->end > right->end) ? left->end : right->end;
+	result->end = (t / result->step) * result->step;
 }
 
 
-unsigned RangeSet_GetSize( void* rangeSet ) {
-	RangeSet*	self = (RangeSet*)rangeSet;
+/*----------------------------------------------------------------------------------------------------------------------------------
+** Private Functions
+*/
 
-	assert( self );
+void RangeSet_GetIndicesParse( void* data, void* _parse ) {
+	RangeSet_Range*		range = (RangeSet_Range*)data;
+	RangeSet_ParseStruct*	parse = (RangeSet_ParseStruct*)_parse;
+	unsigned		nInds, *tmpInds;
 
-	return self->nInds;
+	assert( range );
+	assert( parse );
+
+	tmpInds = parse->inds + parse->nInds;
+	RangeSet_Range_GetIndices( range, &nInds, &tmpInds );
+	parse->nInds += nInds;
 }
 
+void RangeSet_GetRangeParse( void* data, void* _parse ) {
+	RangeSet_Range*		range = (RangeSet_Range*)data;
+	RangeSet_ParseStruct*	parse = (RangeSet_ParseStruct*)_parse;
 
-unsigned RangeSet_GetNRanges( void* rangeSet ) {
-	RangeSet*	self = (RangeSet*)rangeSet;
+	assert( range );
+	assert( parse );
 
-	assert( self );
+	if( parse->curInd++ == parse->nInds )
+		parse->range = range;
+}
 
-	return self->nRanges;
+void RangeSet_IntersectionParse( void* data, void* _parse ) {
+	RangeSet_Range*		range = (RangeSet_Range*)data;
+	RangeSet_ParseStruct*	parse = (RangeSet_ParseStruct*)_parse;
+	unsigned		ind_i;
+
+	assert( range );
+	assert( parse );
+
+	for( ind_i = range->begin; ind_i < range->end; ind_i += range->step ) {
+		if( RangeSet_HasIndex( parse->operand, ind_i ) )
+			parse->inds[parse->nInds++] = ind_i;
+	}
+
+#if 0
+	RangeSet_Range*		range = (RangeSet_Range*)data;
+	RangeSet_ParseStruct*	parse = (RangeSet_ParseStruct*)_parse;
+
+	assert( range );
+	assert( parse );
+
+	parse->range = data;
+	RangeSet_RangeIntersectionParse( parse->operand->btree->root, parse );
+#endif
 }
 
+void RangeSet_SubtractionParse( void* data, void* _parse ) {
+	RangeSet_Range*		range = (RangeSet_Range*)data;
+	RangeSet_ParseStruct*	parse = (RangeSet_ParseStruct*)_parse;
+	unsigned		ind_i;
 
-void RangeSet_GetRange( void* rangeSet, unsigned ind, RangeSet_Range* range ) {
-	RangeSet*	self = (RangeSet*)rangeSet;
+	assert( range );
+	assert( parse );
 
-	assert( self );
-	assert( ind < self->nRanges );
+	for( ind_i = range->begin; ind_i < range->end; ind_i += range->step ) {
+		if( !RangeSet_HasIndex( parse->operand, ind_i ) )
+			parse->inds[parse->nInds++] = ind_i;
+	}
+}
+
+void RangeSet_PickleParse( void* data, void* _parse ) {
+	RangeSet_Range*		range = (RangeSet_Range*)data;
+	RangeSet_ParseStruct*	parse = (RangeSet_ParseStruct*)_parse;
+
 	assert( range );
+	assert( parse );
 
-	memcpy( range, self->ranges + ind, sizeof(RangeSet_Range) );
+	memcpy( parse->bytes + sizeof(unsigned) + parse->curInd, range, sizeof(RangeSet_Range) );
+	parse->curInd += sizeof(RangeSet_Range);
 }
 
+#if 0
+void RangeSet_RangeIntersectionParse( BTreeNode* node, RangeSet_ParseStruct* parse ) {
+	RangeSet_Range*		range;
+	RangeSet_Range		newRng;
+	unsigned		nInds;
 
-void RangeSet_Pickle( void* rangeSet, unsigned* nBytes, Stg_Byte** bytes ) {
-	RangeSet*	self = (RangeSet*)rangeSet;
+	assert( node );
+	assert( node->data );
+	assert( parse );
 
-	assert( self );
-	assert( nBytes );
-	assert( bytes );
+	range = (RangeSet_Range*)node->data;
 
-	if( self->nInds ) {
-		*nBytes = sizeof(unsigned) + self->nRanges * sizeof(RangeSet_Range);
-		*bytes = Memory_Alloc_Array_Unnamed( Stg_Byte, *nBytes );
-		((unsigned*)*bytes)[0] = self->nInds;
-		if( self->nRanges )
-			memcpy( *bytes + sizeof(unsigned), self->ranges, *nBytes - sizeof(unsigned) );
+	if( range->end > parse->range->begin && range->begin < parse->range->end ) {
+		RangeSet_Range_Intersection( range, parse->range, &newRng );
+		nInds = RangeSet_Range_GetNumIndices( &newRng );
+		if( nInds ) {
+			parse->nInds += nInds;
+			BTree_InsertNode( parse->newTree, &newRng, sizeof(RangeSet_Range) );
+		}
 	}
-	else {
-		*nBytes = 0;
-		*bytes = NULL;
-	}
+
+	if( range->begin < parse->range->begin && node->left != NIL )
+		RangeSet_RangeIntersectionParse( node->left, parse );
+	if( range->end > parse->range->end && node->right != NIL )
+		RangeSet_RangeIntersectionParse( node->right, parse );
 }
+#endif
 
-
-/*----------------------------------------------------------------------------------------------------------------------------------
-** Private Functions
-*/
-
 int RangeSet_SortCmp( const void* itema, const void* itemb ) {
 	assert( itema && itemb );
 	return *((unsigned*)itema) - *((unsigned*)itemb);
 }
 
+int RangeSet_DataCompare( void* left, void* right ) {
+	RangeSet_Range*	a = (RangeSet_Range*)left;
+	RangeSet_Range*	b = (RangeSet_Range*)right;
 
+	if( a->begin > b->begin )
+		return 1;
+	else if( a->end < b->begin )
+		return -1;
+	else
+		return 0;
+}
+
+void RangeSet_DataCopy( void** dstData, void* data, SizeT size ) {
+	*dstData = AllocArray( RangeSet_Range, 1 );
+	memcpy( *dstData, data, sizeof(RangeSet_Range) );
+}
+
+void RangeSet_DataDelete( void* data ) {
+	FreeArray( data );
+}
+
+
 void RangeSet_Destruct( RangeSet* self ) {
 	assert( self );
 
-	KillArray( self->ranges );
-	self->nRanges = 0;
 	self->nInds = 0;
+	FreeObject( self->btree );
+	self->btree = BTree_New( RangeSet_DataCompare, RangeSet_DataCopy, RangeSet_DataDelete, NULL, 
+				 BTREE_NO_DUPLICATES );
 }

Modified: long/3D/Gale/trunk/src/StGermain/Base/Container/src/RangeSet.h
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/Container/src/RangeSet.h	2007-02-23 18:02:03 UTC (rev 6081)
+++ long/3D/Gale/trunk/src/StGermain/Base/Container/src/RangeSet.h	2007-02-23 18:02:07 UTC (rev 6082)
@@ -47,12 +47,6 @@
 	/** Virtual function types */
 
 	/** Mesh class contents */
-	typedef struct {
-		unsigned	begin;
-		unsigned	end;
-		unsigned	step;
-	} RangeSet_Range;
-
 	#define __RangeSet				\
 		/* General info */			\
 		__Stg_Class				\
@@ -61,8 +55,7 @@
 							\
 		/* RangeSet info */			\
 		unsigned		nInds;		\
-		unsigned		nRanges;	\
-		RangeSet_Range*		ranges;
+		BTree*			btree;
 
 	struct RangeSet { __RangeSet };
 
@@ -70,10 +63,10 @@
 	** Constructors
 	*/
 
-	#define RANGESET_DEFARGS		\
+	#define RANGESET_DEFARGS \
 		STG_CLASS_DEFARGS
 
-	#define RANGESET_PASSARGS	\
+	#define RANGESET_PASSARGS \
 		STG_CLASS_PASSARGS
 
 	RangeSet* RangeSet_New();
@@ -101,23 +94,42 @@
 	void RangeSet_AddIndices( void* rangeSet, unsigned nInds, unsigned* inds );
 	void RangeSet_SetRange( void* rangeSet, unsigned begin, unsigned end, unsigned step );
 	void RangeSet_Clear( void* rangeSet );
+
+	void RangeSet_GetIndices( void* rangeSet, unsigned* nInds, unsigned** inds );
+	unsigned RangeSet_GetSize( void* rangeSet );
+	unsigned RangeSet_GetNumRanges( void* rangeSet );
+	RangeSet_Range* RangeSet_GetRange( void* rangeSet, unsigned index );
+	Bool RangeSet_HasIndex( void* rangeSet, unsigned index );
+
 	void RangeSet_Union( void* rangeSet, RangeSet* rSet );
 	void RangeSet_Intersection( void* rangeSet, RangeSet* rSet );
 	void RangeSet_Subtraction( void* rangeSet, RangeSet* rSet );
-	void RangeSet_Unpickle( void* rangeSet, unsigned nBytes, Stg_Byte* bytes );
 
-	void RangeSet_GetIndices( void* rangeSet, unsigned* nInds, unsigned** inds );
-	Bool RangeSet_HasIndex( void* rangeSet, unsigned ind );
-	unsigned RangeSet_GetSize( void* rangeSet );
-	unsigned RangeSet_GetNRanges( void* rangeSet );
-	void RangeSet_GetRange( void* rangeSet, unsigned ind, RangeSet_Range* range );
 	void RangeSet_Pickle( void* rangeSet, unsigned* nBytes, Stg_Byte** bytes );
+	void RangeSet_Unpickle( void* rangeSet, unsigned nBytes, Stg_Byte* bytes );
 
+	void RangeSet_Range_Intersection( RangeSet_Range* left, RangeSet_Range* right, RangeSet_Range* result );
+	Bool RangeSet_Range_HasIndex( RangeSet_Range* self, unsigned index );
+	unsigned RangeSet_Range_GetNumIndices( RangeSet_Range* self );
+	void RangeSet_Range_GetIndices( RangeSet_Range* self, unsigned* nInds, unsigned** inds );
+
 	/*--------------------------------------------------------------------------------------------------------------------------
 	** Private Member functions
 	*/
 
+	void RangeSet_GetIndicesParse( void* data, void* _parseStruct );
+	void RangeSet_GetRangeParse( void* data, void* _parseStruct );
+	void RangeSet_IntersectionParse( void* data, void* _parse );
+	void RangeSet_SubtractionParse( void* data, void* _parse );
+	void RangeSet_PickleParse( void* data, void* _parse );
+#if 0
+	void RangeSet_RangeIntersectionParse( BTreeNode* node, RangeSet_ParseStruct* parse );
+#endif
 	int RangeSet_SortCmp( const void* itema, const void* itemb );
+	int RangeSet_DataCompare( void* left, void* right );
+	void RangeSet_DataCopy( void** dstData, void* data, SizeT size );
+	void RangeSet_DataDelete( void* data );
+
 	void RangeSet_Destruct( RangeSet* self );
 
 #endif /* __Base_Container_RangeSet_h__ */

Modified: long/3D/Gale/trunk/src/StGermain/Base/Container/src/types.h
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/Container/src/types.h	2007-02-23 18:02:03 UTC (rev 6081)
+++ long/3D/Gale/trunk/src/StGermain/Base/Container/src/types.h	2007-02-23 18:02:07 UTC (rev 6082)
@@ -107,5 +107,24 @@
 #define LinkedListIterator_Next( it ) \
 	(it==NULL)?NULL:(it->curr == NULL)?NULL:((it->curr = it->curr->next)==NULL)?NULL:it->curr->data
 
+
+	typedef struct {
+		unsigned	begin;
+		unsigned	end;
+		unsigned	step;
+	} RangeSet_Range;
+
+	typedef struct {
+		RangeSet*	self;
+		RangeSet*	operand;
+		RangeSet_Range*	range;
+		BTree*		newTree;
+		unsigned	nInds;
+		unsigned*	inds;
+		unsigned	curInd;
+		Stg_Byte*	bytes;
+	} RangeSet_ParseStruct;
+
+
 #endif /* __Base_Container_types_h__ */
 

Modified: long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testRangeSet.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testRangeSet.c	2007-02-23 18:02:03 UTC (rev 6081)
+++ long/3D/Gale/trunk/src/StGermain/Base/Container/tests/testRangeSet.c	2007-02-23 18:02:07 UTC (rev 6082)
@@ -39,23 +39,12 @@
 #include "Base/Container/Container.h"
 
 
-Bool testConstruct( unsigned rank, unsigned nProcs, unsigned watch ) {
-	RangeSet*	set;
-
-	set = RangeSet_New();
-	FreeObject( set );
-
-	return True;
-}
-
-
 Bool testIndices( unsigned rank, unsigned nProcs, unsigned watch ) {
 	Bool		result = True;
 	unsigned	nInds = 100;
 	unsigned	inds[100];
 	RangeSet*	set;
-	unsigned	nDstInds;
-	unsigned*	dstInds;
+	unsigned	nDstInds, *dstInds;
 	unsigned	i;
 
 	for( i = 0; i < nInds; i++ )
@@ -65,14 +54,15 @@
 
 	RangeSet_SetIndices( set, nInds, inds );
 	if( rank == watch ) {
-		if( set->nInds != nInds || 
-		    set->nRanges != 1 )
+		if( RangeSet_GetSize( set ) != nInds || 
+		    RangeSet_GetNumRanges( set ) != 1 )
 		{
 			result = False;
 			goto done;
 		}
 	}
 
+	dstInds = NULL;
 	RangeSet_GetIndices( set, &nDstInds, &dstInds );
 	if( rank == watch ) {
 		unsigned	ind_i;
@@ -98,12 +88,12 @@
 	return result;
 }
 
-
 Bool testRanges( unsigned rank, unsigned nProcs, unsigned watch ) {
 	Bool		result = True;
 	unsigned	nInds = 100;
 	unsigned	inds[100];
 	RangeSet*	set;
+	unsigned	nDstInds, *dstInds;
 	unsigned	i;
 
 	for( i = 0; i < nInds; i++ )
@@ -113,17 +103,20 @@
 
 	RangeSet_SetIndices( set, nInds, inds );
 	if( rank == watch ) {
-		if( set->nInds != nInds || 
-		    set->nRanges != nInds/10 )
+		if( RangeSet_GetSize( set ) != nInds || 
+		    RangeSet_GetNumRanges( set ) != nInds/10 )
 		{
 			result = False;
 			goto done;
 		}
 
 		for( i = 0; i < nInds; i++ ) {
-			if( set->ranges[i/10].begin != (i/10)*20 || 
-			    set->ranges[i/10].end != (i/10)*20 + 10 || 
-			    set->ranges[i/10].step != 1 )
+			RangeSet_Range*	rng;
+
+			rng = RangeSet_GetRange( set, i / 10 );
+			if( rng->begin != (i/10)*20 || 
+			    rng->end != (i/10)*20 + 10 || 
+			    rng->step != 1 )
 			{
 				result = False;
 				goto done;
@@ -131,18 +124,21 @@
 		}
 	}
 
+	dstInds = NULL;
+	RangeSet_GetIndices( set, &nDstInds, &dstInds );
+
 done:
 	FreeObject( set );
 
 	return result;
 }
 
-
 Bool testUnion( unsigned rank, unsigned nProcs, unsigned watch ) {
 	unsigned	nInds = 100;
 	unsigned	inds[100];
 	RangeSet*	set0;
 	RangeSet*	set1;
+	unsigned	nDstInds, *dstInds;
 	unsigned	i;
 
 	for( i = 0; i < nInds; i++ )
@@ -159,24 +155,27 @@
 	FreeObject( set1 );
 	if( rank == watch ) {
 		if( RangeSet_GetSize( set0 ) != nInds + nInds / 2 || 
-		    RangeSet_GetNRanges( set0 ) != nInds / 10 + nInds / 20 )
+		    RangeSet_GetNumRanges( set0 ) != nInds / 10 + nInds / 20 )
 		{
 			FreeObject( set0 );
 			return False;
 		}
 	}
 
+	dstInds = NULL;
+	RangeSet_GetIndices( set0, &nDstInds, &dstInds );
+
 	FreeObject( set0 );
 
 	return True;
 }
 
-
 Bool testIntersection( unsigned rank, unsigned nProcs, unsigned watch ) {
 	unsigned	nInds = 100;
 	unsigned	inds[100];
 	RangeSet*	set0;
 	RangeSet*	set1;
+	unsigned	nDstInds, *dstInds;
 	unsigned	i;
 
 	for( i = 0; i < nInds; i++ )
@@ -193,24 +192,27 @@
 	FreeObject( set1 );
 	if( rank == watch ) {
 		if( RangeSet_GetSize( set0 ) != nInds / 2 || 
-		    RangeSet_GetNRanges( set0 ) != nInds / 20 )
+		    RangeSet_GetNumRanges( set0 ) != nInds / 20 )
 		{
 			FreeObject( set0 );
 			return False;
 		}
 	}
 
+	dstInds = NULL;
+	RangeSet_GetIndices( set0, &nDstInds, &dstInds );
+
 	FreeObject( set0 );
 
 	return True;
 }
 
-
 Bool testSubtraction( unsigned rank, unsigned nProcs, unsigned watch ) {
 	unsigned	nInds = 100;
 	unsigned	inds[100];
 	RangeSet*	set0;
 	RangeSet*	set1;
+	unsigned	nDstInds, *dstInds;
 	unsigned	i;
 
 	for( i = 0; i < nInds; i++ )
@@ -227,25 +229,28 @@
 	FreeObject( set1 );
 	if( rank == watch ) {
 		if( RangeSet_GetSize( set0 ) != nInds / 2 || 
-		    RangeSet_GetNRanges( set0 ) != nInds / 20 )
+		    RangeSet_GetNumRanges( set0 ) != nInds / 20 )
 		{
 			FreeObject( set0 );
 			return False;
 		}
 	}
 
+	dstInds = NULL;
+	RangeSet_GetIndices( set0, &nDstInds, &dstInds );
+
 	FreeObject( set0 );
 
 	return True;
 }
 
-
 Bool testPickle( unsigned rank, unsigned nProcs, unsigned watch ) {
 	unsigned	nInds = 100;
 	unsigned	inds[100];
 	RangeSet*	set;
 	unsigned	nBytes;
-	Stg_Byte*		bytes;
+	Stg_Byte*	bytes;
+	unsigned	nDstInds, *dstInds;
 	unsigned	i;
 
 	for( i = 0; i < nInds; i++ )
@@ -258,17 +263,20 @@
 	RangeSet_Unpickle( set, nBytes, bytes );
 
 	if( rank == watch ) {
-		if( set->nInds != nInds || 
-		    set->nRanges != nInds/10 )
+		if( RangeSet_GetSize( set ) != nInds || 
+		    RangeSet_GetNumRanges( set ) != nInds/10 )
 		{
 			FreeObject( set );
 			return False;
 		}
 
 		for( i = 0; i < nInds; i++ ) {
-			if( set->ranges[i/10].begin != (i/10)*20 || 
-			    set->ranges[i/10].end != (i/10)*20 + 10 || 
-			    set->ranges[i/10].step != 1 )
+			RangeSet_Range*	rng;
+
+			rng = RangeSet_GetRange( set, i / 10 );
+			if( rng->begin != (i/10)*20 || 
+			    rng->end != (i/10)*20 + 10 || 
+			    rng->step != 1 )
 			{
 				FreeObject( set );
 				return False;
@@ -276,16 +284,18 @@
 		}
 	}
 
+	dstInds = NULL;
+	RangeSet_GetIndices( set, &nDstInds, &dstInds );
+
 	FreeObject( set );
 
 	return True;
 }
 
 
-#define nTests	7
+#define nTests	6
 
-TestSuite_Test	tests[nTests] = {{"construct", testConstruct, 10}, 
-				 {"set indices", testIndices, 10}, 
+TestSuite_Test	tests[nTests] = {{"set indices", testIndices, 10}, 
 				 {"ranges", testRanges, 10 }, 
 				 {"union", testUnion, 10}, 
 				 {"intersection", testIntersection, 10}, 

Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Decomp.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Decomp.c	2007-02-23 18:02:03 UTC (rev 6081)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Decomp.c	2007-02-23 18:02:07 UTC (rev 6082)
@@ -312,7 +312,7 @@
 	}
 	else {
 		nGlobals = RangeSet_GetSize( gSet );
-		if( RangeSet_GetNRanges( gSet ) > 1 )
+		if( RangeSet_GetNumRanges( gSet ) > 1 )
 			return False;
 	}
 

Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/DecompTransfer.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/DecompTransfer.c	2007-02-23 18:02:03 UTC (rev 6081)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/DecompTransfer.c	2007-02-23 18:02:07 UTC (rev 6082)
@@ -482,15 +482,19 @@
 			unsigned	incRank;
 
 			incRank = self->commTopo->incRanks[p_i];
-			if( retSets[incRank] )
+			if( retSets[incRank] ) {
+				self->snks[p_i] = NULL;
 				RangeSet_GetIndices( retSets[incRank], self->nSnks + p_i, self->snks + p_i );
+			}
 			else {
 				self->nSnks[p_i] = 0;
 				self->snks[p_i] = NULL;
 			}
 
-			if( fndSets[incRank] )
+			if( fndSets[incRank] ) {
+				self->srcs[p_i] = NULL;
 				RangeSet_GetIndices( fndSets[incRank], self->nSrcs + p_i, self->srcs + p_i );
+			}
 			else {
 				self->nSrcs[p_i] = 0;
 				self->srcs[p_i] = NULL;

Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Decomp_Sync.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Decomp_Sync.c	2007-02-23 18:02:03 UTC (rev 6081)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Decomp_Sync.c	2007-02-23 18:02:07 UTC (rev 6082)
@@ -416,6 +416,7 @@
 				MPI_Send( bytes, nBytes, MPI_BYTE, p_i, tag, comm );
 				FreeArray( bytes );
 
+				inds = NULL;
 				RangeSet_GetIndices( remReqSet, &nInds, &inds );
 				if( !CommTopology_GlobalToLocal( self->commTopo, p_i, &localRank ) ) {
 					Decomp_Sync_AddRemoteRanks( self, 1, &p_i );
@@ -475,6 +476,7 @@
 				MPI_Recv( bytes, nBytes, MPI_BYTE, active[p_j], tag, comm, &status );
 				RangeSet_Unpickle( reqSet, nBytes, bytes );
 				FreeArray( bytes );
+				inds = NULL;
 				RangeSet_GetIndices( reqSet, &nInds, &inds );
 				insist( CommTopology_GlobalToLocal( self->commTopo, active[p_j], &localRank ) );
 				Decomp_Sync_AddSources( sync, 1, &localRank, &nInds, &inds );
@@ -824,6 +826,7 @@
 		FreeArray( remBytes[p_i] );
 
 		RangeSet_Intersection( remSet, locSet );
+		snks[p_i] = NULL;
 		RangeSet_GetIndices( remSet, nSnks + p_i, snks + p_i );
 		RangeSet_Pickle( remSet, nRemBytes + p_i, remBytes + p_i );
 	}
@@ -848,6 +851,7 @@
 		/* Empty the internal found arrays. */
 		FreeArray( fndBytes[p_i] );
 
+		srcs[p_i] = NULL;
 		RangeSet_GetIndices( remSet, nSrcs + p_i, srcs + p_i );
 	}
 
@@ -900,6 +904,7 @@
 	FreeArray( nRecvBytes );
 
 	/* Use the 'allSet' to generate the shared indices. */
+	self->shared = NULL;
 	RangeSet_GetIndices( allSet, &self->nShared, &self->shared );
 	FreeObject( allSet );
 	for( s_i = 0; s_i < self->nShared; s_i++ ) {
@@ -912,6 +917,7 @@
 	memset( self->nSharers, 0, self->nShared * sizeof(unsigned) );
 	sharers = AllocArray2D( unsigned, self->nShared, nIncRanks );
 	for( r_i = 0; r_i < nIncRanks; r_i++ ) {
+		inds = NULL;
 		RangeSet_GetIndices( rSets[r_i], &nInds, &inds );
 		FreeObject( rSets[r_i] );
 		for( ind_i = 0; ind_i < nInds; ind_i++ ) {
@@ -943,6 +949,7 @@
 	FreeObject( tmpSet );
 
 	/* These indices are the shared elements. */
+	self->shared = NULL;
 	RangeSet_GetIndices( shareSet, &self->nShared, &self->shared );
 	FreeObject( shareSet );
 

Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Decomposer.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Decomposer.c	2007-02-23 18:02:03 UTC (rev 6081)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Decomposer.c	2007-02-23 18:02:07 UTC (rev 6082)
@@ -439,6 +439,7 @@
 	/* Extract local indices. */
 	*decomp = Decomp_New();
 	Decomp_SetComm( *decomp, self->comm );
+	locals = NULL;
 	RangeSet_GetIndices( claimed, &nLocals, &locals );
 	Decomp_SetLocals( *decomp, nLocals, locals );
 	FreeArray( locals );
@@ -452,6 +453,7 @@
 	*sync = Decomp_Sync_New();
 	Decomp_Sync_SetDecomp( *sync, *decomp );
 	Decomp_Sync_SetCommTopology( *sync, commTopo );
+	remotes = NULL;
 	RangeSet_GetIndices( rSet, &nRemotes, &remotes );
 	Decomp_Sync_SetRemotes( *sync, nRemotes, remotes );
 	FreeArray( remotes );

Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshTopology.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshTopology.c	2007-02-23 18:02:03 UTC (rev 6081)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshTopology.c	2007-02-23 18:02:07 UTC (rev 6082)
@@ -195,6 +195,7 @@
 			Decomp_Sync_GetSinks( sync, p_i, &nInds, &inds );
 			RangeSet_AddIndices( bndSet, nInds, inds );
 		}
+		self->bndVerts = NULL;
 		RangeSet_GetIndices( bndSet, &self->nBndVerts, &self->bndVerts );
 		FreeObject( bndSet );
 	}
@@ -787,6 +788,7 @@
 		CommTopology_GetIncidence( commTopo, &nIncRanks, &incRanks );
 		RangeSet_SetIndices( curSet, nIncRanks, incRanks );
 		RangeSet_Subtraction( tmpSet, curSet );
+		incRanks = NULL;
 		RangeSet_GetIndices( tmpSet, &nIncRanks, &incRanks );
 		Decomp_Sync_AddRemoteRanks( sync, nIncRanks, incRanks );
 	}
@@ -1329,6 +1331,7 @@
 				MPI_Send( bytes, nBytes, MPI_BYTE, p_i, tag, comm );
 				FreeArray( bytes );
 
+				inds = NULL;
 				RangeSet_GetIndices( remExtSet, &nInds, &inds );
 				if( !CommTopology_GlobalToLocal( commTopo, p_i, &localRank ) ) {
 					Decomp_Sync_AddRemoteRanks( sync, 1, &p_i );
@@ -1412,6 +1415,7 @@
 				MPI_Recv( bytes, nBytes, MPI_BYTE, active[p_j], tag, comm, &status );
 				RangeSet_Unpickle( extSet, nBytes, bytes );
 				FreeArray( bytes );
+				inds = NULL;
 				RangeSet_GetIndices( extSet, &nInds, &inds );
 				insist( CommTopology_GlobalToLocal( commTopo, active[p_j], &localRank ) );
 				Decomp_Sync_AddSources( sync, 1, &localRank, &nInds, &inds );
@@ -1549,6 +1553,7 @@
 	/* Unpickle sourced bytes. */
 	for( p_i = 0; p_i < nIncRanks; p_i++ ) {
 		RangeSet_Unpickle( tmpSet, nSrcBytes[p_i], srcBytes[p_i] );
+		recvElements[p_i] = NULL;
 		RangeSet_GetIndices( tmpSet, nRecvElements + p_i, recvElements + p_i );
 	}
 
@@ -1857,6 +1862,7 @@
 		RangeSet_AddIndices( rankSet, nItems, newRanks );
 	}
 	FreeArray( newRanks );
+	newRanks = NULL;
 	RangeSet_GetIndices( rankSet, &nNewRanks, &newRanks );
 	Decomp_Sync_AddRemoteRanks( sync, nNewRanks, newRanks );
 	FreeArray( newRanks );



More information about the cig-commits mailing list