freeing lists of structures including possible lists with loops




// call for all pointers to structures when a function ends



func fr1( ptr1 )
{
	if (ptr1->ref_count == 1)
	{
		ptr->ref_count = 2;	// stop at this point if a looping structure


		for each pointer 'ptr' in the structure pointed to by ptr1
		{
			if (ptr->ref_count == 1) 	// if 2 or more, another pointer is pointing into the list
			{
				fr1( ptr );
			}
		}


		dealloc ptr1 
	}			

}		