Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

atoms.h File Reference


Detailed Description

Atom management.

Author:
Raphael Manfredi
Date:
2002-2003

#include <glib.h>

Go to the source code of this file.

Defines

#define ATOM_STRING   0 /**< Strings */
 Strings.

#define ATOM_GUID   1 /**< GUIDs (binary, 16 bytes) */
 GUIDs (binary, 16 bytes).

#define ATOM_SHA1   2 /**< SHA1 (binary, 20 bytes) */
 SHA1 (binary, 20 bytes).

#define ATOM_UINT64   3 /**< integers (binary, 8 bytes) */
 integers (binary, 8 bytes)

#define atom_str_get(k)   atom_get(ATOM_STRING, k)
#define atom_str_free(k)   atom_free(ATOM_STRING, k)
#define atom_guid_get(k)   atom_get(ATOM_GUID, k)
#define atom_guid_free(k)   atom_free(ATOM_GUID, k)
#define atom_sha1_get(k)   atom_get(ATOM_SHA1, k)
#define atom_sha1_free(k)   atom_free(ATOM_SHA1, k)
#define atom_uint64_get(k)   atom_get(ATOM_UINT64, k)
#define atom_uint64_free(k)   atom_free(ATOM_UINT64, k)

Functions

void atoms_init (void)
 Initialize atom structures.

void atoms_close (void)
 Shutdown atom structures, freeing all remaining atoms.

guint uint64_hash (gconstpointer key)
 Calculate the 32-bit hash of a 64-bit integer.

gint uint64_eq (gconstpointer a, gconstpointer b)
 Test two 64-bit integers for equality.

guint sha1_hash (gconstpointer key)
 Hash a SHA1 (20 bytes).

gint sha1_eq (gconstpointer a, gconstpointer b)
 Test two SHA1s for equality.

guint guid_hash (gconstpointer key)
 Hash a GUID (16 bytes).

gint guid_eq (gconstpointer a, gconstpointer b)
 Test two GUIDs for equality.

guint binary_hash (const guchar *key, guint len)
 Hash `len' bytes (multiple of 4) starting from `key'.

gpointer atom_get (gint type, gconstpointer key)
 Get atom of given `type', whose value is `key'.

void atom_free (gint type, gconstpointer key)
 Remove one reference from atom.


Define Documentation

#define ATOM_GUID   1 /**< GUIDs (binary, 16 bytes) */
 

GUIDs (binary, 16 bytes).

#define atom_guid_free  )     atom_free(ATOM_GUID, k)
 

#define atom_guid_get  )     atom_get(ATOM_GUID, k)
 

#define ATOM_SHA1   2 /**< SHA1 (binary, 20 bytes) */
 

SHA1 (binary, 20 bytes).

#define atom_sha1_free  )     atom_free(ATOM_SHA1, k)
 

#define atom_sha1_get  )     atom_get(ATOM_SHA1, k)
 

#define atom_str_free  )     atom_free(ATOM_STRING, k)
 

#define atom_str_get  )     atom_get(ATOM_STRING, k)
 

#define ATOM_STRING   0 /**< Strings */
 

Strings.

#define ATOM_UINT64   3 /**< integers (binary, 8 bytes) */
 

integers (binary, 8 bytes)

#define atom_uint64_free  )     atom_free(ATOM_UINT64, k)
 

#define atom_uint64_get  )     atom_get(ATOM_UINT64, k)
 


Function Documentation

void atom_free gint  type,
gconstpointer  key
 

Remove one reference from atom.

Dispose of atom if nobody references it anymore.

gpointer atom_get gint  type,
gconstpointer  key
 

Get atom of given `type', whose value is `key'.

If the atom does not exist yet, `key' is cloned and makes up the new atom.

Returns:
the atom's value.

void atoms_close void   ) 
 

Shutdown atom structures, freeing all remaining atoms.

void atoms_init void   ) 
 

Initialize atom structures.

guint binary_hash const guchar *  key,
guint  len
 

Hash `len' bytes (multiple of 4) starting from `key'.

gint guid_eq gconstpointer  a,
gconstpointer  b
 

Test two GUIDs for equality.

guint guid_hash gconstpointer  key  ) 
 

Hash a GUID (16 bytes).

gint sha1_eq gconstpointer  a,
gconstpointer  b
 

Test two SHA1s for equality.

Attention:
NB: This routine is visible for the download mesh.

guint sha1_hash gconstpointer  key  ) 
 

Hash a SHA1 (20 bytes).

Attention:
NB: This routine is visible for the download mesh.

gint uint64_eq gconstpointer  a,
gconstpointer  b
 

Test two 64-bit integers for equality.

Returns:
whether both referenced 64-bit integers are equal.

guint uint64_hash gconstpointer  p  ) 
 

Calculate the 32-bit hash of a 64-bit integer.

Returns:
the 32-bit hash value for the referenced 64-bit integer.


Generated on Sun Feb 12 10:49:59 2006 for Gtk-Gnutella by doxygen 1.3.6