X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Freclists.c;h=b9ac9f17b4bec5fb2610799f24e81f64769d613c;hb=41b3d6e76417912fda803543325e1edba21896ba;hp=40f1d76e7695b85dc4e7f5abd353ad1e3e9c386a;hpb=fe3383c0559a453df1e5076fc6faac6d1a11685c;p=pazpar2-moved-to-github.git diff --git a/src/reclists.c b/src/reclists.c index 40f1d76..b9ac9f1 100644 --- a/src/reclists.c +++ b/src/reclists.c @@ -1,9 +1,13 @@ /* - * $Id: reclists.c,v 1.1 2006-12-20 20:47:16 quinn Exp $ + * $Id: reclists.c,v 1.3 2007-01-08 12:43:41 adam Exp $ */ #include +#if HAVE_CONFIG_H +#include +#endif + #include #include "pazpar2.h" @@ -71,7 +75,7 @@ struct record *reclist_insert(struct reclist *l, struct record *record) { unsigned int bucket; struct reclist_bucket **p; - struct record *head; + struct record *head = 0; bucket = hash((unsigned char*) record->merge_key) & l->hashmask; for (p = &l->hashtable[bucket]; *p; p = &(*p)->next) @@ -86,14 +90,18 @@ struct record *reclist_insert(struct reclist *l, struct record *record) break; } } - if (!*p) // We made it to the end of the bucket without finding match + if (!head && l->num_records < l->flatlist_size) { - struct reclist_bucket *new = nmem_malloc(l->nmem, - sizeof(struct reclist_bucket)); + struct reclist_bucket *new = + nmem_malloc(l->nmem, sizeof(struct reclist_bucket)); + + assert(!*p); + new->record = record; record->next_cluster = 0; new->next = 0; *p = new; + assert(l->num_records < l->flatlist_size); l->flatlist[l->num_records++] = record; head = record; }