s3-ldb: update the old ldb in s3 to use new DLIST macros
authorAndrew Tridgell <tridge@samba.org>
Sat, 6 Feb 2010 01:38:47 +0000 (12:38 +1100)
committerJeremy Allison <jra@samba.org>
Wed, 10 Feb 2010 23:38:16 +0000 (15:38 -0800)
(cherry picked from commit a7d8bfd373392eecf4fff33d39b85e1b55ad901d)

source3/lib/ldb/ldb_tdb/ldb_tdb_wrap.c
source3/lib/ldb/modules/paged_results.c

index 2fff74d59a91beb1161418f5d10b998a4eb9ca0e..64463f7c910244391009db16262672db847f16c7 100644 (file)
@@ -45,15 +45,7 @@ static struct ltdb_wrap *tdb_list;
 static int ltdb_wrap_destructor(struct ltdb_wrap *w)
 {
        tdb_close(w->tdb);
 static int ltdb_wrap_destructor(struct ltdb_wrap *w)
 {
        tdb_close(w->tdb);
-       if (w->next) {
-               w->next->prev = w->prev;
-       }
-       if (w->prev) {
-               w->prev->next = w->next;
-       }
-       if (w == tdb_list) {
-               tdb_list = w->next;
-       }
+       DLIST_REMOVE(tdb_list, w);
        return 0;
 }                               
 
        return 0;
 }                               
 
@@ -142,12 +134,7 @@ struct tdb_context *ltdb_wrap_open(TALLOC_CTX *mem_ctx,
 
        talloc_set_destructor(w, ltdb_wrap_destructor);
 
 
        talloc_set_destructor(w, ltdb_wrap_destructor);
 
-       w->next = tdb_list;
-       w->prev = NULL;
-       if (tdb_list) {
-               tdb_list->prev = w;
-       }
-       tdb_list = w;
+       DLIST_ADD(tdb_list, w);
        
        return w->tdb;
 }
        
        return w->tdb;
 }
index 63f9ee67523101dd73995b37d0cd84fa7286d6a0..e16b7104131f8d9405622cb2b8d54fa20e8f2170 100644 (file)
@@ -78,17 +78,7 @@ int store_destructor(struct results_store *store);
 
 int store_destructor(struct results_store *store)
 {
 
 int store_destructor(struct results_store *store)
 {
-       if (store->prev) {
-               store->prev->next = store->next;
-       }
-       if (store->next) {
-               store->next->prev = store->prev;
-       }
-
-       if (store == store->priv->store) {
-               store->priv->store = NULL;
-       }
-
+       DLIST_REMOVE(store->priv->store, store);
        return 0;
 }
 
        return 0;
 }
 
@@ -120,10 +110,7 @@ static struct results_store *new_store(struct private_data *priv)
        newr->controls = NULL;
 
        /* put this entry as first */
        newr->controls = NULL;
 
        /* put this entry as first */
-       newr->prev = NULL;
-       newr->next = priv->store;
-       if (priv->store != NULL) priv->store->prev = newr;
-       priv->store = newr;
+       DLIST_ADD(priv->store, newr);
 
        talloc_set_destructor(newr, store_destructor);
 
 
        talloc_set_destructor(newr, store_destructor);