示例#1
0
void
initLoader(Opts *opts)
{
  G_loader = xmalloc(sizeof(*G_loader));
  G_loader->loadedModules = HashTable_create();
  G_loader->infoTables = HashTable_create();
  G_loader->closures = HashTable_create();

  G_loader->basepaths = NULL;
  initBasepath(&G_loader->basepaths, opts);
}
示例#2
0
void
L_build_jrg_info (L_JRG_Info *jrg_info, L_Cb *cb, L_Oper *jrg_oper)
{
  L_Oper *op;
  L_Flow *fl;
  int case_cnt = 0;
  double weight = cb->weight;
  HashTable h;

  jrg_info->cb = cb;
  jrg_info->jrg = jrg_oper;
  jrg_info->jrg_flows = L_find_flow_for_branch (cb, jrg_oper);
  jrg_info->jrg_default_flow = L_find_last_flow (cb->dest_flow);

  h = HashTable_create (32);
  
  for (op = cb->first_op; op && op != jrg_oper; op = op->next)
    {
      if (!L_is_control_oper (op))
	continue;
      weight -= fl->weight;
      fl = fl->next_flow;
    }

  jrg_info->weight = weight;

  for (; fl; fl = fl->next_flow)
    {
      case_cnt++;
      if ((tgt = HashTable_find_or_null (h, fl->dst_cb->id)))
	{
	  tgt->weight+=fl->weight;
	}
      else
	{
	  tgt = L_ALLOC (L_JRG_Target);
	  tgt->target = fl->dst_cb;
	  tgt->weight = fl->weight;
	  HashTable_insert (h, (void *)tgt);
	}
    }

  jrg_info->target_hash = h;
  return;
}
示例#3
0
int main()
{
	String * myKey, *myKey2, *myValue, *tmpString;
	List * keys; 
	ListIterator * iterator;
	HashTable * table = HashTable_create(500);

	myKey = String_create("Mia");
	myKey2 = String_create("Russell");
	myValue = String_create("shrug");

	HashTable_setValue(table, myKey, String_copy(myValue));
	HashTable_setValue(table, myKey2, String_copy(myValue));

	String_destroy(myValue);

	keys = HashTable_getKeys(table);

	iterator = ListIterator_create(keys);
	tmpString = ListIterator_seekToFirst(iterator);

	while(tmpString != NULL)
	{
		myValue = HashTable_removeValue(table, tmpString);
		printf("Removed -> %s\n", String_c(myValue));
		String_destroy(myValue);
		tmpString = ListIterator_seekToFirst(iterator);
	}

	ListIterator_destroy(iterator);

	String_destroy(myKey);
	String_destroy(myKey2);

	HashTable_destroy(table);
	return 0;
}