/** * Finds a hash in the hash data list and returns the hash_data_t that * corresponds to it. In normal operations it should always find * something. * @param hash_data_list is the list to look into for the hash 'hash' * @param hash is the hash to look for. * @returns the GList * pointer that contains hash_data_t structure that * corresponds to the hash 'hash'. */ static GList *find_hash_in_list(GList *hash_data_list, guint8 *hash) { GList *iter = hash_data_list; hash_data_t *found = NULL; gboolean ok = FALSE; while (iter != NULL && ok == FALSE) { found = iter->data; if (compare_two_hashs(hash, found->hash) == 0) { ok = TRUE; } else { iter = g_list_next(iter); } } if (ok == TRUE) { return iter; } else { return NULL; } }
/** * Tells wheter a hash (picking it in a hash_data_t structure) is in the * needed list of hash_data_t structures. * @param hash_data contains the hash that we are looking for into the * needed list. * @param needed is a GList of hash_data_t structures that may already * contain one with the same hash than the one in hash_data * @returns TRUE if the hash is found, FALSE otherwise */ gboolean hash_data_is_in_list(hash_data_t *hash_data, GList *needed) { gboolean found = FALSE; hash_data_t *needed_hash_data = NULL; if (hash_data != NULL) { while (needed != NULL && found == FALSE) { needed_hash_data = needed->data; if (compare_two_hashs(hash_data->hash, needed_hash_data->hash) == 0) { found = TRUE; } else { needed = g_list_next(needed); } } } return found; }