Example #1
0
void account_del( irc_t *irc, account_t *acc )
{
	account_t *a, *l = NULL;
	
	if( acc->ic )
		/* Caller should have checked, accounts still in use can't be deleted. */
		return;
	
	for( a = irc->accounts; a; a = (l=a)->next )
		if( a == acc )
		{
			if( l )
				l->next = a->next;
			else
				irc->accounts = a->next;
			
			while( a->set )
				set_del( &a->set, a->set->key );
			
			g_hash_table_destroy( a->nicks );
			
			g_free( a->user );
			g_free( a->pass );
			g_free( a->server );
			if( a->reconnect )	/* This prevents any reconnect still queued to happen */
				cancel_auto_reconnect( a );
			g_free( a );
			
			break;
		}
}
Example #2
0
void bee_free( bee_t *b )
{
	while( b->accounts )
	{
		if( b->accounts->ic )
			imc_logout( b->accounts->ic, FALSE );
		else if( b->accounts->reconnect )
			cancel_auto_reconnect( b->accounts );
		
		if( b->accounts->ic == NULL )
			account_del( b, b->accounts );
		else
			/* Nasty hack, but account_del() doesn't work in this
			   case and we don't want infinite loops, do we? ;-) */
			b->accounts = b->accounts->next;
	}
	
	while( b->set )
		set_del( &b->set, b->set->key );
	
	bee_group_free( b );
	
	g_free( b->user );
	g_free( b );
}
Example #3
0
File: hamt.c Project: 4n3w/dump
void *hamt_delete(struct hamt_root *root, uint128_t *hash)
{
	if (unlikely(ston(root->slot) == NULL)) {
		return NULL;
	}

	struct hamt_state s;
        s.level = 0;
        s.ptr[0] = &root->slot;

	void *found_item = __hamt_search(root, hash, &s);
	if (unlikely(found_item == NULL)) {
		return NULL;
	}
	if (unlikely(s.level == 0)) {
		root->slot = (struct hamt_slot){0};
		goto done;
	}
	struct hamt_slot *found_slot = s.ptr[s.level];
	s.level--;

	struct hamt_node *node = ston(*s.ptr[s.level]);

	int slice = slice_get(*hash, s.level);
	if (set_count(node->mask) != 2) {
		*s.ptr[s.level] = ntos(__hamt_del_node(root, node, slice));
		goto done;
	} else { // set_count == 2
		struct hamt_slot other_slot = \
			__hamt_get_other_slot(node, found_slot);
		if(!is_leaf(&other_slot)) {
			uint64_t other_slice = set_first(set_del(node->mask, slice));
			__hamt_free_node(root, node);
			*s.ptr[s.level] = ntos(__hamt_new_node1(root, other_slice, other_slot));
			goto done;
		} else {
			while (1) {
				__hamt_free_node(root, node);
				if (unlikely(s.level == 0)) {
					root->slot = other_slot;
					goto done;
				}

				s.level--;
				node = ston(*s.ptr[s.level]);
				if (set_count(node->mask) != 1) {
					break;
				}
			}
			slice = slice_get(*hash, s.level);
			int slot = set_slot_number(node->mask, slice);
			node->slots[slot] = other_slot;
			goto done;
		}
	}
done:
	return found_item;
}
Example #4
0
int irc_channel_free(irc_channel_t *ic)
{
	irc_t *irc;
	GSList *l;

	if (ic == NULL) {
		return 0;
	}
	irc = ic->irc;

	if (ic->flags & IRC_CHANNEL_JOINED) {
		irc_channel_del_user(ic, irc->user, IRC_CDU_KICK, "Cleaning up channel");
	}

	if (ic->f->_free) {
		ic->f->_free(ic);
	}

	while (ic->set) {
		set_del(&ic->set, ic->set->key);
	}

	irc->channels = g_slist_remove(irc->channels, ic);
	while (ic->users) {
		g_free(ic->users->data);
		ic->users = g_slist_remove(ic->users, ic->users->data);
	}

	for (l = irc->users; l; l = l->next) {
		irc_user_t *iu = l->data;

		if (iu->last_channel == ic) {
			iu->last_channel = irc->default_channel;
		}
	}

	if (ic->pastebuf_timer) {
		b_event_remove(ic->pastebuf_timer);
	}

	g_free(ic->name);
	g_free(ic->topic);
	g_free(ic->topic_who);
	g_free(ic);

	return 1;
}
Example #5
0
static void __ohamt_delete(struct ohamt_root *root, uint128_t hash,
			   struct ohamt_state *s)
{
	if (unlikely(s->level == 0)) {
		root->slot = (struct ohamt_slot){0};
		goto done;
	}
	struct ohamt_slot *found_slot = s->ptr[s->level];
	s->level--;

	struct ohamt_node *node = ston(*s->ptr[s->level]);

	int slice = slice_get(hash, s->level);
	if (set_count(node->mask) != 2) {
		*s->ptr[s->level] = ntos(__ohamt_del_node(root, node, slice));
		goto done;
	} else { // set_count == 2
		struct ohamt_slot other_slot = \
			__ohamt_get_other_slot(node, found_slot);
		if(!is_leaf(&other_slot)) {
			uint64_t other_slice = set_first(set_del(node->mask, slice));
			__ohamt_free_node(root, node);
			*s->ptr[s->level] = ntos(__ohamt_new_node1(root, other_slice, other_slot));
			goto done;
		} else {
			while (1) {
				__ohamt_free_node(root, node);
				if (unlikely(s->level == 0)) {
					root->slot = other_slot;
					goto done;
				}

				s->level--;
				node = ston(*s->ptr[s->level]);
				if (set_count(node->mask) != 1) {
					break;
				}
			}
			slice = slice_get(hash, s->level);
			int slot = set_slot_number(node->mask, slice);
			node->slots[slot] = other_slot;
			goto done;
		}
	}
done:
	return;
}
Example #6
0
void account_del(bee_t *bee, account_t *acc)
{
	account_t *a, *l = NULL;

	if (acc->ic) {
		/* Caller should have checked, accounts still in use can't be deleted. */
		return;
	}

	for (a = bee->accounts; a; a = (l = a)->next) {
		if (a == acc) {
			if (l) {
				l->next = a->next;
			} else {
				bee->accounts = a->next;
			}

			/** FIXME
			for( c = bee->chatrooms; c; c = nc )
			{
			        nc = c->next;
			        if( acc == c->acc )
			                chat_del( bee, c );
			}
			*/

			while (a->set) {
				set_del(&a->set, a->set->key);
			}

			g_hash_table_destroy(a->nicks);

			g_free(a->tag);
			g_free(a->user);
			g_free(a->pass);
			g_free(a->server);
			if (a->reconnect) {     /* This prevents any reconnect still queued to happen */
				cancel_auto_reconnect(a);
			}
			g_free(a);

			break;
		}
	}
}
Example #7
0
File: hamt.c Project: 4n3w/dump
static struct hamt_node *__hamt_del_node(struct hamt_root *root,
					 struct hamt_node *old_node,
					 int slice)
{
	int slot = set_slot_number(old_node->mask, slice);
	int old_size = set_count(old_node->mask);
	int new_size = old_size - 1;
	struct hamt_node *node = __hamt_new_node(root,
						 set_del(old_node->mask, slice),
						 new_size);
	memcpy(&node->slots[0], &old_node->slots[0],
	       sizeof(struct hamt_slot)*slot);
	memcpy(&node->slots[slot], &old_node->slots[slot+1],
	       sizeof(struct hamt_slot)*(old_size-slot-1));

	__hamt_free_node(root, old_node);
	return node;
}
Example #8
0
void client_del(struct TClient* client)
{
int newcount = g_clients.m_count - 1;
struct TClient* clients = (struct TClient*)malloc( sizeof(struct TClient) * newcount );

int index;
for (index = 0; (g_clients.m_client+index) != client && index < g_clients.m_count; ++index)
    {
    clients[index] = g_clients.m_client[index];
    }

set_del( client2set( 0 ) + index );

for (++index; index < g_clients.m_count; ++index)
    {
    clients[index-1] = g_clients.m_client[index];
    }

free( g_clients.m_client );
g_clients.m_client = clients;
g_clients.m_count = newcount;
}
Example #9
0
File: jabber.c Project: AlD/bitlbee
void jabber_chat_free_settings( account_t *acc, set_t **head )
{
	set_del( head, "password" );
}
Example #10
0
void detect_last_diagram_number(void)
{
   long l=0;
   FILE *input_file=NULL;
   char tmp[MAX_STR_LEN], *ptr;
   int i;
   long max_diagram_number;
      max_diagram_number = (sizeof(int) < 4 )?MAX_DIAGRAM_NUMBER_S:MAX_DIAGRAM_NUMBER_L;
      input_file=open_system_file(input_name);

      /* Go to the <end of input file>-100 -- we want to determine
      the number of diagram: */

       /*go to end of file:*/
      if(fseek(input_file, 0L, SEEK_END)) halt(DISKPROBLEM,NULL);
       /*get position:*/
      if((l=ftell(input_file))==-1) halt(DISKPROBLEM,NULL);
       /*go back for 100 bytes:*/
      if(fseek(input_file, (l>100)?(l-100):0L, SEEK_SET))
         halt(DISKPROBLEM,NULL);
      *tmp=0;l=0;
      do{
        if((i=s_pos("*--#] d",tmp))!=-1){
           ptr=tmp+i+7;
           while((*ptr!=':')&&(*ptr))ptr++;
           *ptr=0;
           sscanf(tmp+i+7,"%ld",&l);
        }
      }while(fgets(tmp, MAX_STR_LEN, input_file)!=NULL);
      close_file(&input_file);
      if(l==0)halt(CURRUPTEDINPUT,input_name);
      if(l>max_diagram_number)halt(MAXDIAGRAM,NULL);
      /* Now l == last diagran number.*/
      if(start_diagram==0)
         start_diagram=1;
      if((finish_diagram==0)||(finish_diagram>l))
         finish_diagram=l;
      if (start_diagram>finish_diagram){
         sprintf(tmp, WRRONGSTARTNUMBER,start_diagram,finish_diagram);
         halt(tmp,NULL);
      }
      /* Now we know size of the dmask*/
      dmask_size=l/250 + 1;
      dmask=get_mem(dmask_size,sizeof(set_of_char));
      if(xi_list_top!=NULL){
         struct list_struct *top=xi_list_top;
            while(top!=NULL){
               if(top->from < start_diagram)
                  top->from=start_diagram;
               if(top->to > finish_diagram)
                  top->to=finish_diagram;
               for(l=top->from;!(l>top->to);l++){
                 if(top->xi=='x')/*ATTENTION! We use inverse order!*/
                   set_set((l % 250),dmask[l / 250]);
                 else/*ATTENTION! We use inverse order!*/
                   set_del((l % 250),dmask[l / 250]);
               }
               xi_list_top=top->next;
               free_mem(&top);
               top=xi_list_top;
            }
      }
      if (is_bit_set(&mode,bitBROWS))
        diagram=get_mem(finish_diagram-start_diagram+1,
           sizeof(struct diagram_struct));
}/*detect_last_diagram_number*/