Exemplo n.º 1
0
int hashmap_size(hashmap_t * hash) {
	int count = 0;
	list_t * keys = hashmap_keys(hash);
	foreach(key, keys)
		count++;
	list_freeall(keys);
	return count;
}
void hashmap_delete(t_hashmap* map)
{
	t_hashmap_key* keys = hashmap_keys(map);
	int i;
	for (i = 0; i < keys->length; i++)
	{
		hashmap_remove(map, keys->keys[i]);
	}

	free(keys);
	free(map);
}
Exemplo n.º 3
0
char * get_username_from_pid(int pid) {
	char * username = NULL;
	list_t * keys = hashmap_keys(multishell_sessions);
	foreach(key,keys)
		if((int)hashmap_get(multishell_sessions, key->value) == pid) {
			int usr_size = strlen(key->value);
			username = malloc(usr_size);
			memset(username, 0, usr_size);
			memcpy(username, key->value, usr_size);
			username[usr_size] = '\0';
			break;
		}
	list_freeall(keys);
	return username;
}