Exemplo n.º 1
0
/* main program */
int main( int argc, char **argv ) { 
  char word[ MAX_WORD_LEN ];
  Node node;
  char def[ MAX_WORD_LEN ];
  while ( 1 ) {
    if ( isalpha( getword(word, MAX_WORD_LEN) ) ) {
      getword(def, MAX_WORD_LEN);
      if ( (node = install( word, def )) == NULL ) {
	printf( "error: low memory\n" );
	break;
      } else {
	printf( "installed '%s -- %s'\n", node->name, node->def );
      }
    } else {
      break; /* time for undef */
    }
  }
  printf( "after install, the hashtable looks like:\n" );
  hashwalk();
  Node tmp = (Node) malloc( sizeof( *tmp ) );
  while ( getword(word, MAX_WORD_LEN) != EOF ) {
    if ( lookup( word ) != NULL ) {
      printf( "macro '%s' is in the table\n", word );
    } else {
      printf( "macro '%s' is not in the table\n", word );
    }
    printf( "removing macro '%s'\n", word );
    undef( word, tmp );
    if ( strcmp( tmp->name, "####" ) == 0 ) {
      printf( "Whoops: No such macro '%s'\n", word );
    } else {
      printf( "macro '%s' -- '%s', has been removed\n", tmp->name, tmp->def );
    }
  }
  printf( "after undef, the hashtable looks like:\n" );
  hashwalk();
  free( tmp );
  hashfree();
  return 0;
}
Exemplo n.º 2
0
void hashfree(hash_t* hash){
  hashfree(_blockStore, hash);
}