Ejemplo n.º 1
0
//
// find edges
//
matrix_t* findEdges(matrix_t* matrix1, float allowedDifference)
{
	matrix_t* result;
	int x,y;
	
	// sanity check parameters
	if(!matrix_create(&result, matrix1->rows, matrix1->cols)) 
	{
		perror("failed to create result");		
		return 0;
	}

	for (y = 0; y < matrix1->rows; ++y)
	{
		for (x = 0; x < matrix1->cols; ++x)
		{
			// check parameters
			char tooDifferent = 0;
			if (y > 0)
				tooDifferent |=
					cellDifference(matrix1, x, y, x, y - 1) > allowedDifference;
			
			if (y < matrix1->rows)
				tooDifferent |=
					cellDifference(matrix1, x, y, x, y + 1) > allowedDifference;
			
			if (x > 0)
				tooDifferent |=
					cellDifference(matrix1, x, y, x - 1, y) > allowedDifference;
			
			if (x < matrix1->cols)
				tooDifferent |=
					cellDifference(matrix1, x, y, x + 1, y) > allowedDifference;
			
			//get matrix position
			element_t* res = matrix_index(result, x, y);
			res->red = res->green = res->blue =
				tooDifferent ? 1 : 0;
		}
	}
	
	return result;
}
const char* MemoryLeakWarning::FinalReport(int toBeDeletedLeaks)
{
	TInt cellDifference(User::CountAllocCells() - _impl->iInitialAllocCells);
	if( cellDifference != toBeDeletedLeaks ) {
		return "Heap imbalance after test\n";
	}
	
	TInt processHandles;
	TInt threadHandles;
	RThread().HandleCount(processHandles, threadHandles);
	
	if(_impl->iInitialProcessHandleCount != processHandles ||
		_impl->iInitialThreadHandleCount != threadHandles) {
		return "Handle count imbalance after test\n";
	}
	
	return "";
}