summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2018-05-07 16:41:55 +0200
committerKarolin Seeger <kseeger@samba.org>2018-09-28 09:17:22 +0200
commit59682787ad97674c49c084acd161bb81aacb16b8 (patch)
tree2c0dcd4347d934af43c2907dc097a82c02dfbaa9
parentdccaea50ce57d6718ffd937cc8b97b64c98c0e79 (diff)
downloadsamba-59682787ad97674c49c084acd161bb81aacb16b8.tar.gz
lib: Put "results_store" into a doubly linked list
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13362 Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> (cherry picked from commit 8063995a92fffc93aa9d6d1d92a75bf3f3c9592b)
-rw-r--r--lib/ldb/modules/paged_results.c25
1 files changed, 5 insertions, 20 deletions
diff --git a/lib/ldb/modules/paged_results.c b/lib/ldb/modules/paged_results.c
index de014a39699..aafbcbf4483 100644
--- a/lib/ldb/modules/paged_results.c
+++ b/lib/ldb/modules/paged_results.c
@@ -35,6 +35,7 @@
#include "replace.h"
#include "system/filesys.h"
#include "system/time.h"
+#include "dlinklist.h"
#include "ldb_module.h"
struct message_store {
@@ -48,14 +49,13 @@ struct message_store {
struct private_data;
struct results_store {
+ struct results_store *prev, *next;
struct private_data *priv;
char *cookie;
time_t timestamp;
- struct results_store *next;
-
struct message_store *first;
struct message_store *last;
int num_entries;
@@ -75,22 +75,8 @@ struct private_data {
static int store_destructor(struct results_store *del)
{
struct private_data *priv = del->priv;
- struct results_store *loop;
-
- if (priv->store == del) {
- priv->store = del->next;
- return 0;
- }
-
- for (loop = priv->store; loop; loop = loop->next) {
- if (loop->next == del) {
- loop->next = del->next;
- return 0;
- }
- }
-
- /* is not in list ? */
- return -1;
+ DLIST_REMOVE(priv->store, del);
+ return 0;
}
static struct results_store *new_store(struct private_data *priv)
@@ -120,8 +106,7 @@ static struct results_store *new_store(struct private_data *priv)
newr->first_ref = NULL;
newr->controls = NULL;
- newr->next = priv->store;
- priv->store = newr;
+ DLIST_ADD(priv->store, newr);
talloc_set_destructor(newr, store_destructor);