link-grammar-5.8.0/link-grammar/parse/prune.c
/**
 * This runs through all the connectors in this table, and eliminates those
 * with a zero reference count.
 * In order to support a unique uppercase part per hash entry, we need to
 * ensure that a collision chain doesn't break when the last remaining
 * connector in an entry is removed. To that end, if the entry is not last
 * in the chain, instead of removing it we replace it with a permanent
 * "tombstone" connector that cannot match.
 */
This runs through all the connectors in this table, and eliminates those
with a zero reference count.
In order to support a unique uppercase part per hash entry, we need to
ensure that a collision chain doesn't break when the last remaining
connector in an entry is removed. To that end, if the entry is not last
in the chain, instead of removing it we replace it with a permanent
"tombstone" connector that cannot match.
This runs through all the connectors in this table and eliminates those with a zero reference count . In order to support a unique uppercase part per hash entry we need to ensure that a collision chain doesn ' t break when the last remaining connector in an entry is removed . To that end if the entry is not last in the chain instead of removing it we replace it with a permanent " tombstone " connector that cannot match .
static void clean_table(unsigned int size, C_list **t)
{
	static condesc_t desc_no_match =
	{
		.uc_num = (connector_hash_t)-1, 
	};
	static Connector con_no_match =
	{
		.desc = &desc_no_match,
		.refcount = 1,    
		.shallow = false, 
	};
	for (unsigned int i = 0; i < size; i++)
	{
		C_list **m = &t[i];
		while (NULL != *m)
		{
			assert(0 <= (*m)->c->refcount, "clean_table: refcount < 0 (%d)",
			       (*m)->c->refcount);
			if (0 == (*m)->c->refcount)
			{
				if ((*m == t[i]) && (NULL == (*m)->next) && 
				    (NULL != t[(i+1) & (size-1)]))          
				{
					(*m)->c = &con_no_match;                 
				}
				else
				{
					*m = (*m)->next;
				}
			}
			else
			{
				m = &(*m)->next;
			}
		}
	}
}
static void clean_table ( unsigned int size , C_list * * t ) { static condesc_t desc_no_match = { . uc_num = ( connector_hash_t ) - 1 , } ; static Connector con_no_match = { . desc = & desc_no_match , . refcount = 1 , . shallow = false , } ; for ( unsigned int i = 0 ; i < size ; i ++ ) { C_list * * m = & t [ i ] ; while ( NULL != * m ) { assert ( 0 <= ( * m ) -> c -> refcount , " " , ( * m ) -> c -> refcount ) ; if ( 0 == ( * m ) -> c -> refcount ) { if ( ( * m == t [ i ] ) && ( NULL == ( * m ) -> next ) && ( NULL != t [ ( i + 1 ) & ( size - 1 ) ] ) ) { ( * m ) -> c = & con_no_match ; } else { * m = ( * m ) -> next ; } } else { m = & ( * m ) -> next ; } } } }
This runs through all the connectors in this table, and eliminates those
 with a zero reference count.
This runs through all the connectors in this table and eliminates those with a zero reference count .
/* Table entry tombstone. */ /* get_power_table_entry() will skip. */ /* Ensure it will not get removed. */ /* Faster mismatch + get_num_con_uc() skips it. */ /* Nothing remains. */ /* Not end of chain. */ /* Place a tombstone. */