libvirt/src/hash.h

69 lines
1.5 KiB
C
Raw Normal View History

2005-11-30 13:36:58 +00:00
/*
* Summary: Chained hash tables and domain/connections handling
* Description: This module implements the hash table and allocation and
* deallocation of domains and connections
2005-11-30 13:36:58 +00:00
*
* Copy: Copyright (C) 2005 Red Hat, Inc.
2005-11-30 13:36:58 +00:00
*
* Author: Bjorn Reese <bjorn.reese@systematic.dk>
* Daniel Veillard <veillard@redhat.com>
2005-11-30 13:36:58 +00:00
*/
#ifndef __VIR_HASH_H__
#define __VIR_HASH_H__
2005-11-30 13:36:58 +00:00
#ifdef __cplusplus
extern "C" {
#endif
/*
* The hash table.
*/
typedef struct _virHashTable virHashTable;
typedef virHashTable *virHashTablePtr;
2005-11-30 13:36:58 +00:00
/*
* function types:
*/
2005-11-30 13:36:58 +00:00
/**
* virHashDeallocator:
2005-11-30 13:36:58 +00:00
* @payload: the data in the hash
* @name: the name associated
*
* Callback to free data from a hash.
*/
typedef void (*virHashDeallocator) (void *payload, char *name);
2005-11-30 13:36:58 +00:00
/*
* Constructor and destructor.
*/
virHashTablePtr virHashCreate(int size);
void virHashFree(virHashTablePtr table, virHashDeallocator f);
int virHashSize(virHashTablePtr table);
2005-11-30 13:36:58 +00:00
/*
* Add a new entry to the hash table.
*/
int virHashAddEntry(virHashTablePtr table,
const char *name, void *userdata);
int virHashUpdateEntry(virHashTablePtr table,
const char *name,
void *userdata, virHashDeallocator f);
2005-11-30 13:36:58 +00:00
/*
* Remove an entry from the hash table.
*/
int virHashRemoveEntry(virHashTablePtr table,
const char *name, virHashDeallocator f);
2005-11-30 13:36:58 +00:00
/*
* Retrieve the userdata.
*/
void *virHashLookup(virHashTablePtr table, const char *name);
2005-11-30 13:36:58 +00:00
#ifdef __cplusplus
}
#endif
#endif /* ! __VIR_HASH_H__ */