summaryrefslogtreecommitdiff
path: root/source3/include
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-08-16 10:44:06 +0200
committerVolker Lendecke <vl@samba.org>2009-08-16 12:38:19 +0200
commit1a22baa817291f5d067dccfb9e4b754781d2fb6f (patch)
tree4e9d07e689aab2746ea5a91447ece51e970ae47a /source3/include
parent5ae122ed7a76e984cc9a8524c03a94bfe42232e3 (diff)
downloadsamba-1a22baa817291f5d067dccfb9e4b754781d2fb6f.tar.gz
samba-1a22baa817291f5d067dccfb9e4b754781d2fb6f.tar.bz2
samba-1a22baa817291f5d067dccfb9e4b754781d2fb6f.zip
s3: Add talloc_dict.[ch]
Diffstat (limited to 'source3/include')
-rw-r--r--source3/include/includes.h1
-rw-r--r--source3/include/talloc_dict.h60
2 files changed, 61 insertions, 0 deletions
diff --git a/source3/include/includes.h b/source3/include/includes.h
index 2d82e6e57e..87df3b7d31 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -689,6 +689,7 @@ struct smb_iconv_convenience *lp_iconv_convenience(void *lp_ctx);
#include "memcache.h"
#include "async_smb.h"
#include "../lib/async_req/async_sock.h"
+#include "talloc_dict.h"
#include "services.h"
#include "eventlog.h"
#include "../lib/util/smb_threads.h"
diff --git a/source3/include/talloc_dict.h b/source3/include/talloc_dict.h
new file mode 100644
index 0000000000..8305f8d15e
--- /dev/null
+++ b/source3/include/talloc_dict.h
@@ -0,0 +1,60 @@
+/*
+ Unix SMB/CIFS implementation.
+ Little dictionary style data structure based on dbwrap_rbt
+ Copyright (C) Volker Lendecke 2009
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __TALLOC_DICT_H__
+#define __TALLOC_DICT_H__
+
+#include "includes.h"
+
+struct talloc_dict;
+
+/*
+ * Create a talloc_dict structure.
+ */
+
+struct talloc_dict *talloc_dict_init(TALLOC_CTX *mem_ctx);
+
+/*
+ * Add a talloced object to the dict. Nulls out the pointer to indicate that
+ * the talloc ownership has been taken. If an object for "key" already exists,
+ * the existing object is talloc_free()ed and overwritten by the new
+ * object. If "data" is NULL, object for key "key" is deleted. Return false
+ * for "no memory".
+ */
+
+bool talloc_dict_set(struct talloc_dict *dict, DATA_BLOB key, void *data);
+
+/*
+ * Fetch a talloced object. If "mem_ctx!=NULL", talloc_move the object there
+ * and delete it from the dict.
+ */
+
+void *talloc_dict_fetch(struct talloc_dict *dict, DATA_BLOB key,
+ TALLOC_CTX *mem_ctx);
+
+/*
+ * Traverse a talloc_dict. If "fn" returns non-null, quit the traverse
+ */
+
+int talloc_dict_traverse(struct talloc_dict *dict,
+ int (*fn)(DATA_BLOB key, void *data,
+ void *private_data),
+ void *private_data);
+
+#endif