-/* $Id: command.c,v 1.1 2006-12-20 20:47:16 quinn Exp $ */
+/* $Id: command.c,v 1.2 2006-12-20 22:19:35 adam Exp $ */
#include <stdio.h>
#include <sys/socket.h>
int num = 10;
int merged, total;
int i;
+ NMEM nmem_show = nmem_create();
if (argc == 2)
num = atoi(argv[1]);
- recs = show(s->psession, 0, &num, &merged, &total);
+ recs = show(s->psession, 0, &num, &merged, &total, nmem_show);
for (i = 0; i < num; i++)
{
}
command_puts(s, "\n");
}
+ nmem_destroy(nmem_show);
return 1;
}
/*
- * $Id: http_command.c,v 1.1 2006-12-20 20:47:16 quinn Exp $
+ * $Id: http_command.c,v 1.2 2006-12-20 22:19:35 adam Exp $
*/
#include <stdio.h>
struct http_response *rs = c->response;
struct http_session *s = locate_session(rq, rs);
struct record **rl;
+ NMEM nmem_show;
char *start = http_argbyname(rq, "start");
char *num = http_argbyname(rq, "num");
int startn = 0;
if (num)
numn = atoi(num);
- rl = show(s->psession, startn, &numn, &total, &total_hits);
+ nmem_show = nmem_create();
+ rl = show(s->psession, startn, &numn, &total, &total_hits, nmem_show);
wrbuf_rewind(c->wrbuf);
wrbuf_puts(c->wrbuf, "<show>\n<status>OK</status>\n");
wrbuf_puts(c->wrbuf, "</show>\n");
rs->payload = nmem_strdup(c->nmem, wrbuf_buf(c->wrbuf));
http_send_response(c);
+ nmem_destroy(nmem_show);
}
static void show_records_ready(void *data)
-/* $Id: pazpar2.c,v 1.1 2006-12-20 20:47:16 quinn Exp $ */;
+/* $Id: pazpar2.c,v 1.2 2006-12-20 22:19:35 adam Exp $ */;
#include <stdlib.h>
#include <stdio.h>
zquery->u.type_1 = ccl_rpn_query(global_parameters.odr_out, cn);
ccl_rpn_delete(cn);
- for (ndb = 0; *db->databases[ndb]; ndb++)
+ for (ndb = 0; db->databases[ndb]; ndb++)
;
databaselist = odr_malloc(global_parameters.odr_out, sizeof(char*) * ndb);
- for (ndb = 0; *db->databases[ndb]; ndb++)
+ for (ndb = 0; db->databases[ndb]; ndb++)
databaselist[ndb] = db->databases[ndb];
a->u.presentRequest->preferredRecordSyntax =
strcpy(database->url, url);
strcat(database->url, "/");
strcat(database->url, db);
- strcpy(database->databases[0], db);
- *database->databases[1] = '\0';
+
+ database->databases = xmalloc(2 * sizeof(char *));
+ database->databases[0] = xstrdup(db);
+ database->databases[1] = 0;
database->errors = 0;
database->next = databases;
databases = database;
return termlist_highscore(s->termlist, num);
}
-struct record **show(struct session *s, int start, int *num, int *total, int *sumhits)
+void report_nmem_stats(void)
{
- struct record **recs = nmem_malloc(s->nmem, *num * sizeof(struct record *));
+ size_t in_use, is_free;
+
+ nmem_get_memory_in_use(&in_use);
+ nmem_get_memory_free(&is_free);
+
+ yaz_log(YLOG_LOG, "nmem stat: use=%ld free=%ld",
+ (long) in_use, (long) is_free);
+}
+
+struct record **show(struct session *s, int start, int *num, int *total,
+ int *sumhits, NMEM nmem_show)
+{
+ struct record **recs = nmem_malloc(nmem_show, *num
+ * sizeof(struct record *));
int i;
relevance_prepare_read(s->relevance, s->reclist);
#include "relevance.h"
#include "eventl.h"
-#define MAX_DATABASES 512
-
struct record {
struct client *client;
int target_offset;
struct database {
struct host *host;
char *url;
- char databases[MAX_DATABASES][128];
+ char **databases;
int errors;
struct database *next;
};
int load_targets(struct session *s, const char *fn);
void statistics(struct session *s, struct statistics *stat);
char *search(struct session *s, char *query);
-struct record **show(struct session *s, int start, int *num, int *total, int *sumhits);
+struct record **show(struct session *s, int start, int *num, int *total, int *sumhits, NMEM nmem_show);
struct termlist_score **termlist(struct session *s, int *num);
void session_set_watch(struct session *s, int what, session_watchfun fun, void *data);