1
/**************************************************************************
3
* Copyright 2008 VMware, Inc.
6
* Permission is hereby granted, free of charge, to any person obtaining a
7
* copy of this software and associated documentation files (the
8
* "Software"), to deal in the Software without restriction, including
9
* without limitation the rights to use, copy, modify, merge, publish,
10
* distribute, sub license, and/or sell copies of the Software, and to
11
* permit persons to whom the Software is furnished to do so, subject to
12
* the following conditions:
14
* The above copyright notice and this permission notice (including the
15
* next paragraph) shall be included in all copies or substantial portions
18
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
**************************************************************************/
30
* Generic handle table.
32
* @author José Fonseca <jfonseca@vmware.com>
35
#ifndef U_HANDLE_TABLE_H_
36
#define U_HANDLE_TABLE_H_
45
* Abstract data type to map integer handles to objects.
47
* Also referred as "pointer array".
53
handle_table_create(void);
57
* Set an optional destructor callback.
59
* If set, it will be called during handle_table_remove and
60
* handle_table_destroy calls.
63
handle_table_set_destroy(struct handle_table *ht,
64
void (*destroy)(void *object));
70
* Returns a zero handle on failure (out of memory).
73
handle_table_add(struct handle_table *ht,
77
* Returns zero on failure (out of memory).
80
handle_table_set(struct handle_table *ht,
85
* Fetch an existing object.
87
* Returns NULL for an invalid handle.
90
handle_table_get(struct handle_table *ht,
95
handle_table_remove(struct handle_table *ht,
100
handle_table_destroy(struct handle_table *ht);
104
handle_table_get_first_handle(struct handle_table *ht);
108
handle_table_get_next_handle(struct handle_table *ht,
116
#endif /* U_HANDLE_TABLE_H_ */