2
* $Id: namesize.c,v 1.9 2004/01/14 20:52:33 rmanfredi Exp $
4
* Copyright (c) 2002-2003, Raphael Manfredi
6
* Handling of the (name, size) tuples.
8
*----------------------------------------------------------------------
9
* This file is part of gtk-gnutella.
11
* gtk-gnutella is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation; either version 2 of the License, or
14
* (at your option) any later version.
16
* gtk-gnutella is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
21
* You should have received a copy of the GNU General Public License
22
* along with gtk-gnutella; if not, write to the Free Software
24
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
*----------------------------------------------------------------------
28
#include "common.h" /* For safe compilation under USE_DMALLOC */
30
#include "override.h" /* Must be the last header included */
32
RCSID("$Id: namesize.c,v 1.9 2004/01/14 20:52:33 rmanfredi Exp $");
37
* Hash a `namesize_t' key.
39
guint namesize_hash(gconstpointer key)
41
const namesize_t *k = (const namesize_t *) key;
44
hash = g_str_hash(k->name);
53
* Compare two `namesize_t' keys.
55
gint namesize_eq(gconstpointer a, gconstpointer b)
57
const namesize_t *ka = a;
58
const namesize_t *kb = b;
60
return ka->size == kb->size && 0 == strcmp(ka->name, kb->name);
66
* Create a new namesize structure.
68
namesize_t *namesize_make(const gchar *name, guint32 size)
72
ns = walloc(sizeof(*ns));
73
ns->name = atom_str_get(name);
82
* Free a namesize structure.
84
void namesize_free(namesize_t *ns)
86
atom_str_free(ns->name);
87
wfree(ns, sizeof(*ns));