static void session_clear_set(struct session *se, struct reclist_sortparms *sp)
{
reclist_destroy(se->reclist);
- se->reclist = 0;
if (nmem_total(se->nmem))
session_log(se, YLOG_DEBUG, "NMEN operation usage %zd",
nmem_total(se->nmem));
session->number_of_warnings_unknown_elements = 0;
session->number_of_warnings_unknown_metadata = 0;
session->num_termlists = 0;
- session->reclist = 0;
+ session->reclist = reclist_create(nmem);
session->clients_active = 0;
session->clients_cached = 0;
session->settings_modified = 0;
session_enter(se, "show_single_start");
*prev_r = 0;
*next_r = 0;
- if (se->reclist)
- {
- reclist_limit(se->reclist, se);
+ reclist_limit(se->reclist, se);
- reclist_enter(se->reclist);
- while ((r = reclist_read_record(se->reclist)))
+ reclist_enter(se->reclist);
+ while ((r = reclist_read_record(se->reclist)))
+ {
+ if (!strcmp(r->recid, id))
{
- if (!strcmp(r->recid, id))
- {
- *next_r = reclist_read_record(se->reclist);
- break;
- }
- *prev_r = r;
+ *next_r = reclist_read_record(se->reclist);
+ break;
}
- reclist_leave(se->reclist);
+ *prev_r = r;
}
+ reclist_leave(se->reclist);
if (!r)
session_leave(se, "show_single_start");
return r;
client_update_show_stat(rec->client, 1);
}
}
- if (*num > 0)
- recs =
- nmem_malloc(se->nmem, *num * sizeof(struct record_cluster *));
+ recs = nmem_malloc(se->nmem, (*num > 0 ? *num : 1) * sizeof(*recs));
for (i = 0; i < *num; i++)
{
struct record_cluster *r = reclist_read_record(se->reclist);
va_start(ap, fmt);
yaz_vsnprintf(buf, sizeof(buf)-30, fmt, ap);
- yaz_log(level, "Session %u: %s", s->session_id, buf);
+ yaz_log(level, "Session %u: %s", s ? s->session_id : 0, buf);
va_end(ap);
}