symboltable.c
/* search the symbol table for items matching given values */
search the symbol table for items matching given values
search the symbol table for items matching given values
const char *find_symbol_with_int_value(symbol_table st, int search)
{
	symbol_table_internal *symbol_table_p = reveal(st);
	int num_entries = symbol_table_p->num_entries;
	int i;
    char *result = NULL;
	char *tmp = malloc(20); 
	sprintf(tmp, "%d", search);
	symbol_table_p->found_key = 0;
	for (i=0; i<num_entries; i++)
	{
		const char *value = symbol_table_p->sym[i].value;
		if (strcmp(value, tmp) == 0)
		{
			symbol_table_p->found_key = 1;
			result = symbol_table_p->sym[i].name;
            break;
		}
	}
    free(tmp);
	return result;	
}
const char * find_symbol_with_int_value ( symbol_table st , int search ) { symbol_table_internal * symbol_table_p = reveal ( st ) ; int num_entries = symbol_table_p -> num_entries ; int i ; char * result = NULL ; char * tmp = malloc ( 20 ) ; sprintf ( tmp , " " , search ) ; symbol_table_p -> found_key = 0 ; for ( i = 0 ; i < num_entries ; i ++ ) { const char * value = symbol_table_p -> sym [ i ] . value ; if ( strcmp ( value , tmp ) == 0 ) { symbol_table_p -> found_key = 1 ; result = symbol_table_p -> sym [ i ] . name ; break ; } } free ( tmp ) ; return result ; }
search the symbol table for items matching given values
search the symbol table for items matching given values
/* should be large enough for most values */