Skip to content

Commit

Permalink
lib: Put "results_store" into a doubly linked list
Browse files Browse the repository at this point in the history
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13362
Signed-off-by: Volker Lendecke <[email protected]>
Reviewed-by: Jeremy Allison <[email protected]>
  • Loading branch information
vlendec authored and jrasamba committed May 15, 2018
1 parent a0f0350 commit 8063995
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions lib/ldb/modules/paged_results.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 8063995

Please sign in to comment.