Logo Search packages:      
Sourcecode: tucnak2 version File versions  Download package

hash.c

/*
    Tucnak - VHF contest log
    Copyright (C) 2002-2006  Ladislav Vaiz <ok1zia@nagano.cz>

    This program is free software; you can redistribute it and/or                                                        
    modify it under the terms of the GNU General Public License                                                          
    version 2 as published by the Free Software Foundation.

*/

#include "header.h"

void hash_safe_insert(GHashTable *table, gchar *key, gchar *value){
    gpointer orig_key;
    gpointer orig_value;

    if (g_hash_table_lookup_extended(table, (gpointer) key, &orig_key, &orig_value)) {
        g_hash_table_remove(table, orig_key);
        g_free(orig_key);
        g_free(orig_value);
    }
    g_hash_table_insert(table, key, value);
}

gboolean free_gstr(gpointer key, gpointer value, gpointer user_data){
    if (key)       g_free(key);
    if (value)     g_free(value);
    if (user_data) g_free(user_data);

    return TRUE;
}

void free_hash(GHashTable *hash){
    if (!hash) return;
    g_hash_table_foreach_remove(hash, free_gstr, NULL);
    g_hash_table_destroy(hash);
}


Generated by  Doxygen 1.6.0   Back to index