source: vendor/current/lib/util/idtree.h

Last change on this file was 988, checked in by Silvan Scherrer, 9 years ago

Samba Server: update vendor to version 4.4.3

File size: 2.1 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3
4 very efficient functions to manage mapping a id (such as a fnum) to
5 a pointer. This is used for fnum and search id allocation.
6
7 Copyright (C) Andrew Tridgell 2004
8
9 This code is derived from lib/idr.c in the 2.6 Linux kernel, which was
10 written by Jim Houston jim.houston@ccur.com, and is
11 Copyright (C) 2002 by Concurrent Computer Corporation
12
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program. If not, see <http://www.gnu.org/licenses/>.
25*/
26
27#ifndef _SAMBA_IDTREE_H_
28#define _SAMBA_IDTREE_H_
29
30#include <talloc.h>
31
32struct idr_context;
33
34/**
35 initialise a idr tree. The context return value must be passed to
36 all subsequent idr calls. To destroy the idr tree use talloc_free()
37 on this context
38 */
39struct idr_context *idr_init(TALLOC_CTX *mem_ctx);
40
41/**
42 allocate the next available id, and assign 'ptr' into its slot.
43 you can retrieve later this pointer using idr_find()
44*/
45int idr_get_new(struct idr_context *idp, void *ptr, int limit);
46
47/**
48 allocate a new id, giving the first available value greater than or
49 equal to the given starting id
50*/
51int idr_get_new_above(struct idr_context *idp, void *ptr, int starting_id, int limit);
52
53/**
54 allocate a new id randomly in the given range
55*/
56int idr_get_new_random(struct idr_context *idp, void *ptr, int limit);
57
58/**
59 find a pointer value previously set with idr_get_new given an id
60*/
61void *idr_find(struct idr_context *idp, int id);
62
63/**
64 remove an id from the idr tree
65*/
66int idr_remove(struct idr_context *idp, int id);
67
68#endif /* _SAMBA_IDTREE_H_ */
Note: See TracBrowser for help on using the repository browser.