aboutsummaryrefslogtreecommitdiff
path: root/sprinter-text.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-text.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-text.c')
-rw-r--r--sprinter-text.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/sprinter-text.c b/sprinter-text.c
index c75ec5be..99330a94 100644
--- a/sprinter-text.c
+++ b/sprinter-text.c
@@ -114,7 +114,7 @@ text_map_key (unused (struct sprinter *sp), unused (const char *key))
}
struct sprinter *
-sprinter_text_create (const void *ctx, FILE *stream)
+sprinter_text_create (notmuch_database_t *db, FILE *stream)
{
static const struct sprinter_text template = {
.vtable = {
@@ -134,21 +134,22 @@ sprinter_text_create (const void *ctx, FILE *stream)
};
struct sprinter_text *res;
- res = talloc (ctx, struct sprinter_text);
+ res = talloc (db, struct sprinter_text);
if (! res)
return NULL;
*res = template;
+ res->vtable.notmuch = db;
res->stream = stream;
return &res->vtable;
}
struct sprinter *
-sprinter_text0_create (const void *ctx, FILE *stream)
+sprinter_text0_create (notmuch_database_t *db, FILE *stream)
{
struct sprinter *sp;
- sp = sprinter_text_create (ctx, stream);
+ sp = sprinter_text_create (db, stream);
if (! sp)
return NULL;