lib: Remove talloc_dict
authorVolker Lendecke <vl@samba.org>
Sun, 6 Aug 2017 13:51:49 +0000 (15:51 +0200)
committerRalph Boehme <slow@samba.org>
Sat, 30 Sep 2017 06:01:24 +0000 (08:01 +0200)
Looked like a good idea at its time, but its only user did not need
it anyway

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/include/talloc_dict.h [deleted file]
source3/lib/talloc_dict.c [deleted file]
source3/selftest/tests.py
source3/torture/torture.c
source3/wscript_build

diff --git a/source3/include/talloc_dict.h b/source3/include/talloc_dict.h
deleted file mode 100644 (file)
index 8305f8d..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-   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
diff --git a/source3/lib/talloc_dict.c b/source3/lib/talloc_dict.c
deleted file mode 100644 (file)
index 7594679..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
-   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/>.
-*/
-
-#include "includes.h"
-#include "dbwrap/dbwrap.h"
-#include "dbwrap/dbwrap_rbt.h"
-#include "talloc_dict.h"
-#include "util_tdb.h"
-
-struct talloc_dict {
-       struct db_context *db;
-};
-
-struct talloc_dict *talloc_dict_init(TALLOC_CTX *mem_ctx)
-{
-       struct talloc_dict *result;
-
-       result = talloc(mem_ctx, struct talloc_dict);
-       if (result == NULL) {
-               return NULL;
-       }
-       result->db = db_open_rbt(result);
-       if (result->db == NULL) {
-               TALLOC_FREE(result);
-               return NULL;
-       }
-       return result;
-}
-
-/*
- * 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 *pdata)
-{
-       struct db_record *rec;
-       NTSTATUS status = NT_STATUS_OK;
-       void *data = *(void **)pdata;
-       TDB_DATA value;
-
-       rec = dbwrap_fetch_locked(dict->db, talloc_tos(),
-                                 make_tdb_data(key.data, key.length));
-       if (rec == NULL) {
-               return false;
-       }
-
-       value = dbwrap_record_get_value(rec);
-
-       if (value.dsize != 0) {
-               void *old_data;
-               if (value.dsize != sizeof(void *)) {
-                       TALLOC_FREE(rec);
-                       return false;
-               }
-               memcpy(&old_data, value.dptr, sizeof(old_data));
-               TALLOC_FREE(old_data);
-               if (data == NULL) {
-                       status = dbwrap_record_delete(rec);
-               }
-       }
-       if (data != NULL) {
-               void *mydata = talloc_move(dict->db, &data);
-               *(void **)pdata = NULL;
-               status = dbwrap_record_store(rec,
-                                            make_tdb_data((uint8_t *)&mydata,
-                                            sizeof(mydata)), 0);
-       }
-       TALLOC_FREE(rec);
-       return NT_STATUS_IS_OK(status);
-}
-
-/*
- * 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)
-{
-       struct db_record *rec;
-       void *result;
-       TDB_DATA value;
-
-       rec = dbwrap_fetch_locked(dict->db, talloc_tos(),
-                                 make_tdb_data(key.data, key.length));
-       if (rec == NULL) {
-               return NULL;
-       }
-
-       value = dbwrap_record_get_value(rec);
-       if (value.dsize != sizeof(void *)) {
-               TALLOC_FREE(rec);
-               return NULL;
-       }
-       result = *(void **)value.dptr;
-
-       if (mem_ctx != NULL) {
-               NTSTATUS status;
-               status = dbwrap_record_delete(rec);
-               if (!NT_STATUS_IS_OK(status)) {
-                       TALLOC_FREE(rec);
-                       return NULL;
-               }
-               result = talloc_move(mem_ctx, &result);
-       }
-
-       return result;
-}
-
-struct talloc_dict_traverse_state {
-       int (*fn)(DATA_BLOB key, void *data, void *private_data);
-       void *private_data;
-};
-
-static int talloc_dict_traverse_fn(struct db_record *rec, void *private_data)
-{
-       TDB_DATA key;
-       TDB_DATA value;
-       struct talloc_dict_traverse_state *state =
-               (struct talloc_dict_traverse_state *)private_data;
-       void *p;
-
-       key = dbwrap_record_get_key(rec);
-       value = dbwrap_record_get_value(rec);
-
-       if (value.dsize != sizeof(void *)) {
-               return -1;
-       }
-
-       memcpy(&p, value.dptr, sizeof(p));
-       return state->fn(data_blob_const(key.dptr, key.dsize),
-                        p, state->private_data);
-}
-
-/*
- * 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)
-{
-       struct talloc_dict_traverse_state state;
-       NTSTATUS status;
-       int count = 0;
-
-       state.fn = fn;
-       state.private_data = private_data;
-       status = dbwrap_traverse(dict->db, talloc_dict_traverse_fn, &state,
-                                &count);
-       if (!NT_STATUS_IS_OK(status)) {
-               return -1;
-       } else {
-               return count;
-       }
-}
index 73479fc5fcde9c259540e96df346880678d04253..1c40e7e049bf8b881235ccc5c9ba7a3f58e5e190 100755 (executable)
@@ -124,7 +124,6 @@ plantestsuite("samba3.smbtorture_s3.plain(%s).%s" % (env, t), env, [os.path.join
 local_tests = [
     "LOCAL-SUBSTITUTE",
     "LOCAL-GENCACHE",
-    "LOCAL-TALLOC-DICT",
     "LOCAL-BASE64",
     "LOCAL-RBTREE",
     "LOCAL-MEMCACHE",
index 4667517e0083b0e67b0f8bf74af25f3142714d98..bb4908fd127ca5e51a910bbec4a07e09038e7019 100644 (file)
@@ -31,7 +31,6 @@
 #include "dbwrap/dbwrap.h"
 #include "dbwrap/dbwrap_open.h"
 #include "dbwrap/dbwrap_rbt.h"
-#include "talloc_dict.h"
 #include "async_smb.h"
 #include "libsmb/libsmb.h"
 #include "libsmb/clirap.h"
@@ -10314,61 +10313,6 @@ failed:
        return false;
 }
 
-
-struct talloc_dict_test {
-       int content;
-};
-
-static int talloc_dict_traverse_fn(DATA_BLOB key, void *data, void *priv)
-{
-       int *count = (int *)priv;
-       *count += 1;
-       return 0;
-}
-
-static bool run_local_talloc_dict(int dummy)
-{
-       struct talloc_dict *dict;
-       struct talloc_dict_test *t;
-       int key, count, res;
-       bool ok;
-
-       dict = talloc_dict_init(talloc_tos());
-       if (dict == NULL) {
-               return false;
-       }
-
-       t = talloc(talloc_tos(), struct talloc_dict_test);
-       if (t == NULL) {
-               return false;
-       }
-
-       key = 1;
-       t->content = 1;
-       ok = talloc_dict_set(dict, data_blob_const(&key, sizeof(key)), &t);
-       if (!ok) {
-               return false;
-       }
-
-       count = 0;
-       res = talloc_dict_traverse(dict, talloc_dict_traverse_fn, &count);
-       if (res == -1) {
-               return false;
-       }
-
-       if (count != 1) {
-               return false;
-       }
-
-       if (count != res) {
-               return false;
-       }
-
-       TALLOC_FREE(dict);
-
-       return true;
-}
-
 static bool run_local_string_to_sid(int dummy) {
        struct dom_sid sid;
 
@@ -11657,7 +11601,6 @@ static struct {
        { "PIDHIGH", run_pidhigh },
        { "LOCAL-SUBSTITUTE", run_local_substitute, 0},
        { "LOCAL-GENCACHE", run_local_gencache, 0},
-       { "LOCAL-TALLOC-DICT", run_local_talloc_dict, 0},
        { "LOCAL-DBWRAP-WATCH1", run_dbwrap_watch1, 0 },
        { "LOCAL-DBWRAP-WATCH2", run_dbwrap_watch2, 0 },
        { "LOCAL-DBWRAP-DO-LOCKED1", run_dbwrap_do_locked1, 0 },
index 3f7fdff8dd358c6928dacf70f72dd11be7da0eab..e9852f04f11b193a8ee008f12ef9b3c629270b77 100644 (file)
@@ -382,7 +382,6 @@ bld.SAMBA3_SUBSYSTEM('samba3core',
                           lib/messages.c
                           lib/util_cluster.c
                           lib/id_cache.c
-                          lib/talloc_dict.c
                           lib/serverid.c
                           lib/server_id_watch.c
                           lib/server_id_db_util.c