aboutsummaryrefslogtreecommitdiff
path: root/sprinter-json.c
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2022-01-01 08:01:34 -0400
committerDavid Bremner <david@tethera.net>2022-01-18 08:08:22 -0400
commit417d202e642e0af0ef692e3ce250a6af985c7442 (patch)
tree8617b002f1883a834ecb37a4e28d46749268c1c5 /sprinter-json.c
parent78e6cf12c05222c324110aa1eb9df9d99baa91a1 (diff)
CLI: stash pointer to database in sprinter structs
We already use an allocated (and presumably open) database as a talloc context. Keeping the pointer in the allocated struct will allow us to e.g. interrogate the configuration in a sprinter function without threading the database all the way through the various levels of function.
Diffstat (limited to 'sprinter-json.c')
-rw-r--r--sprinter-json.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sprinter-json.c b/sprinter-json.c
index c7f4851c..502f89fb 100644
--- a/sprinter-json.c
+++ b/sprinter-json.c
@@ -172,7 +172,7 @@ json_separator (struct sprinter *sp)
}
struct sprinter *
-sprinter_json_create (const void *ctx, FILE *stream)
+sprinter_json_create (notmuch_database_t *db, FILE *stream)
{
static const struct sprinter_json template = {
.vtable = {
@@ -192,11 +192,12 @@ sprinter_json_create (const void *ctx, FILE *stream)
};
struct sprinter_json *res;
- res = talloc (ctx, struct sprinter_json);
+ res = talloc (db, struct sprinter_json);
if (! res)
return NULL;
*res = template;
+ res->vtable.notmuch = db;
res->stream = stream;
return &res->vtable;
}