struct http_response *rs)
{
struct http_argument *a;
+ NMEM nmem = nmem_create();
for (a = rq->arguments; a; a = a->next)
if (strchr(a->name, '['))
char *setting;
// Nmem_strsplit *rules*!!!
- nmem_strsplit(se->session_nmem, "[]", a->name, &res, &num);
+ nmem_strsplit(nmem, "[]", a->name, &res, &num);
if (num != 2)
{
error(rs, PAZPAR2_MALFORMED_SETTING, a->name);
+ nmem_destroy(nmem);
return -1;
}
setting = res[0];
dbname = res[1];
- session_apply_setting(se, dbname, setting,
- nmem_strdup(se->session_nmem, a->value));
+ session_apply_setting(se, dbname, setting, a->value);
}
+ nmem_destroy(nmem);
return 0;
}
{
struct session *se = (struct session *) client_data;
- session_apply_setting(se, nmem_strdup(se->session_nmem, set->target),
- nmem_strdup(se->session_nmem, set->name),
- nmem_strdup(se->session_nmem, set->value));
+ session_apply_setting(se, set->target, set->name, set->value);
}
static void cmd_settings(struct http_channel *c)
// Probably session_init_databases_fun should be refactored instead of
// called here.
static struct session_database *load_session_database(struct session *se,
- char *id)
+ const char *id)
{
struct database *db = new_database_inherit_settings(id, se->session_nmem, se->service->settings);
session_init_databases_fun((void*) se, db);
// Find an existing session database. If not found, load it
static struct session_database *find_session_database(struct session *se,
- char *id)
+ const char *id)
{
struct session_database *sdb;
}
// Apply a session override to a database
-void session_apply_setting(struct session *se, char *dbname, char *name,
- char *value)
+void session_apply_setting(struct session *se, const char *dbname,
+ const char *name, const char *value)
{
session_enter(se, "session_apply_setting");
{
{
s = nmem_malloc(se->session_nmem, sizeof(*s));
s->precedence = 0;
- s->target = dbname;
- s->name = name;
+ s->target = nmem_strdup(se->session_nmem, dbname);
+ s->name = nmem_strdup(se->session_nmem, name);
s->next = sdb->settings[offset];
sdb->settings[offset] = s;
}
- s->value = value;
+ s->value = nmem_strdup(se->session_nmem, value);
}
session_leave(se, "session_apply_setting");
}
int session_set_watch(struct session *s, int what, session_watchfun fun, void *data, struct http_channel *c);
int session_active_clients(struct session *s);
int session_is_preferred_clients_ready(struct session *s);
-void session_apply_setting(struct session *se, char *dbname, char *setting, char *value);
+void session_apply_setting(struct session *se, const char *dbname,
+ const char *setting, const char *value);
const char *session_setting_oneval(struct session_database *db, int offset);
int ingest_record(struct client *cl, const char *rec, int record_no, NMEM nmem);