next = endLayer;
next = (LO_Element *) endLayer;
lo_rl_FitLayer( lo_RelayoutState *relay_state, LO_Element *lo_ele ){	LO_LayerStruct *layerEle = (LO_LayerStruct *)lo_ele;	LO_Element *next = lo_tv_GetNextLayoutElement( relay_state->doc_state, lo_ele, TRUE );		if(layerEle && layerEle->is_end == FALSE)	{		LO_LayerStruct *endLayer = NULL;		LO_Element *lastFloat = NULL;		LO_CellStruct *cell = NULL;		lo_AppendToLineList( relay_state->context, relay_state->doc_state, lo_ele, 0 );		lo_rl_SetLayerDimensions( relay_state, layerEle->initParams );		lo_BeginLayerReflow( relay_state->context, relay_state->doc_state, layerEle->initParams,			layerEle->layerDoc );		if (next->lo_any.type == LO_CELL)		{			/* We are reflowing an ILAYER */			cell = (LO_CellStruct *) next;			/* Set "next" to the layout element following the LO_CELL */			next = lo_tv_GetNextLayoutElement( relay_state->doc_state, next, TRUE);			/* Set the cell's next pointer to null.  We've got to fool the end layer			code into thinking that this cell is the last element on the line list. */			cell->next = NULL;		}		else		{			/* We are reflowing a LAYER.  So, we get the cell from the lo_LayerDocState structure */			lo_LayerDocState *layerDoc = (lo_LayerDocState *) layerEle->layerDoc;			cell = layerDoc->cell;		}		/* Assert that next is a dummy layout element marking the end of the layer */		XP_ASSERT(next->lo_any.type == LO_LAYER && next->lo_layer.is_end == TRUE);		endLayer = (LO_LayerStruct *) next;		next = cell->cell_list;		if (next)		{			/* The next layout element to be fitted is the first element on the cell list.			   Once the cell list has been fitted we want to end the layer, so we append			   the end layer element to the cell list. */			XP_ASSERT(cell->cell_list_end && cell->cell_list_end->lo_any.next == NULL);			cell->cell_list_end->lo_any.next = (LO_Element*) endLayer;			/* We also need to append the cell's float list to the state's float list */			lastFloat = lo_GetLastElementInList(relay_state->doc_state->float_list);			if (lastFloat)				lastFloat->lo_any.next = cell->cell_float_list;						}		else		{			/* There is nothing on the cell's line list to reflow.  So, the float list should			   also be null.  The next element to be fitted is set to the end layer element. */			XP_ASSERT(cell->cell_float_list == NULL);			next = endLayer;		}				/* Since the elements inside the layer are going to be reflowed while state->layer_nest_level		   is greater than zero, lo_FlushLineList() will append the layout elements onto the cell's 		   line list.  So, the cell's line list and float lists need to be initialized to null. */		if (cell)		{			cell->cell_list = NULL;			cell->cell_float_list = NULL;			cell->cell_list_end = NULL;		}				}	else	{		lo_EndLayerReflow( relay_state->context, relay_state->doc_state );		lo_AppendToLineList( relay_state->context, relay_state->doc_state, lo_ele, 0 );	}			return next;}