1 /*******************************************************************
2 uLan Utilities Library - C library of basic reusable constructions
4 ul_uniqid.h - unique ID generator
6 (C) Copyright 2003-2004 by Pavel Pisa - Originator
8 The uLan utilities library can be used, copied and modified under
10 - GPL - GNU General Public License
11 - LGPL - GNU Lesser General Public License
12 - MPL - Mozilla Public License
13 - and other licenses added by project originators
14 Code can be modified and re-distributed under any combination
15 of the above listed licenses. If contributor does not agree with
16 some of the licenses, he/she can delete appropriate line.
17 Warning, if you delete all lines, you are not allowed to
18 distribute source code and/or binaries utilizing code.
20 See files COPYING and README for details.
22 *******************************************************************/
30 typedef unsigned long ul_uniqid_t;
32 typedef struct ul_uniqid_range_t {
38 * struct ul_uniqid_pool_t - The Unique Identifiers Pool
39 * @items: GAVL tree of not allocated yet ranges
40 * @range: numeric range to allocate IDs from
42 * The unique pool provides functions to manage unique numerical IDs.
43 * The pool is first initialized by function ul_uniqid_pool_init().
44 * The available range is specified at this time. The pool can be
45 * flushed and destroyed by call ul_uniqid_pool_done().
47 * The function ul_uniqid_pool_alloc_one() returns first free ID from
48 * range. The ID is returned to the pool by function ul_uniqid_pool_free_one().
49 * There are even functions to reserve and release specific IDs range.
51 typedef struct ul_uniqid_pool_t {
52 gavl_fles_int_root_field_t items;
53 ul_uniqid_range_t range;
56 int ul_uniqid_pool_init(ul_uniqid_pool_t *pool, ul_uniqid_t first, ul_uniqid_t last);
57 int ul_uniqid_pool_done(ul_uniqid_pool_t *pool);
58 int ul_uniqid_pool_reserve(ul_uniqid_pool_t *pool, ul_uniqid_t first, ul_uniqid_t last);
59 int ul_uniqid_pool_release(ul_uniqid_pool_t *pool, ul_uniqid_t first, ul_uniqid_t last);
60 int ul_uniqid_pool_alloc_one(ul_uniqid_pool_t *pool, ul_uniqid_t *ptrid);
61 int ul_uniqid_pool_alloc_one_after(ul_uniqid_pool_t *pool, ul_uniqid_t *ptrid, ul_uniqid_t afterid);
62 int ul_uniqid_pool_free_one(ul_uniqid_pool_t *pool, ul_uniqid_t id);
65 #endif /*_UL_UNIQID_H*/