Esempio n. 1
0
Connection *createConnection(void) {
	Connection *conn = NULL;
	ListElement *elem = NULL;

	if (!(conn = malloc(sizeof(Connection))))
		ERREXIT("Cannot allocate memory for connection.");

	pthread_rwlock_init(&(conn->state.rwlock), NULL);

	pthread_mutex_init(&(conn->sock.mtx), NULL);

	conn->state.value = RUSP_CLOSED;

	conn->sock.fd = -1;

	elem = CONPOOL.head;

	while (elem) {

		if (getConnectionState((Connection *) elem->value) == RUSP_TIMEWT) {

			usleep(RUSP_TIMEWTTM);

			elem = CONPOOL.head;

		} else {

			elem = elem->next;
		}
	}

	conn->connid = (ConnectionId) addElementToList(&CONPOOL, conn);

	return conn;
}
Esempio n. 2
0
main()
{
  ll * start=NULL;
  int ch;
  while(1)
  {
    printf("\n1. Add an element \n2. Get an element \n3.Exit");
    scanf("%d",&ch);
    switch(ch)
    {
      case 1:
	printf("\nEnter the element to be inserted : ");
	scanf("%d",&ch);
	addElementToList(&start,ch);
	printf("Element Added");
	break;
      case 2:
	printf("\nEnter the index");
	scanf("%d",&ch);
	getElement(ch);
	break;
      default:
	exit(0);
    }
    
  }
  
}
Esempio n. 3
0
void addElementToHashset(struct HashSet *hashset, const char *word)
{
	unsigned int code;

	code = hashset->hashFunc(word, hashset->numberBuckets);
	addElementToList(hashset->buckets[code], word);
}
void FSFloaterWSAssetBlacklist::buildBlacklist()
{
	blacklist_data_t data = FSWSAssetBlacklist::instance().getBlacklistData();
	
	for (blacklist_data_t::const_iterator iterator = data.begin(); iterator != data.end(); ++iterator)
	{
		addElementToList(iterator->first, iterator->second);
	}
}