00001 /* 00002 * $Id: idtable.h,v 1.5 2005/06/29 14:24:26 daichik Exp $ 00003 * 00004 * Copyright (c) 2001-2003, Richard Eckart 00005 * 00006 *---------------------------------------------------------------------- 00007 * This file is part of gtk-gnutella. 00008 * 00009 * gtk-gnutella is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * gtk-gnutella is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with gtk-gnutella; if not, write to the Free Software 00021 * Foundation, Inc.: 00022 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00023 *---------------------------------------------------------------------- 00024 */ 00025 00055 #ifndef _idtable_h_ 00056 #define _idtable_h_ 00057 00058 #include <glib.h> 00059 00060 #define idtable_ids(tbl) (tbl->ids) 00061 #define idtable_size(tbl) (tbl->size) 00062 00063 typedef struct idtable { 00064 guint32 size; 00065 guint32 esize; 00066 guint32 ids; 00067 guint32 last_id; 00068 guint32 *used_ids; 00069 gpointer *data; 00070 } idtable_t; 00071 00072 idtable_t *idtable_new(guint32 isize, guint32 esize); 00073 00074 void idtable_destroy(idtable_t *table); 00075 00076 guint32 idtable_new_id(idtable_t *tbl, gpointer value); 00077 void idtable_new_id_value(idtable_t *tbl, guint32 id, gpointer value); 00078 00079 void idtable_free_id(idtable_t *tbl, guint32 id); 00080 00081 G_INLINE_FUNC gboolean idtable_is_id_used(idtable_t *tbl, guint32 id); 00082 00083 void idtable_set_value(idtable_t *tbl, guint32 id, gpointer value); 00084 gpointer idtable_get_value(idtable_t *tbl, guint32 id); 00085 00086 #endif /* _idtable_h_ */