From 25e0619c01a0373dffc237cc95ee37d90fe0ff01 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 17 Jun 2021 19:55:56 +0300 Subject: [PATCH] lib: Add istream_snapshot.free() to allow more complex snapshots --- src/lib/istream-private.h | 1 + src/lib/istream.c | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lib/istream-private.h b/src/lib/istream-private.h index ac31294859..c1180a5746 100644 --- a/src/lib/istream-private.h +++ b/src/lib/istream-private.h @@ -73,6 +73,7 @@ struct istream_private { struct istream_snapshot { struct istream_snapshot *prev_snapshot; struct memarea *old_memarea; + void (*free)(struct istream_snapshot *snapshot); }; enum istream_create_flag { diff --git a/src/lib/istream.c b/src/lib/istream.c index 93c5703470..7c79e7dcf3 100644 --- a/src/lib/istream.c +++ b/src/lib/istream.c @@ -243,9 +243,13 @@ void i_stream_snapshot_free(struct istream_snapshot **_snapshot) *_snapshot = NULL; i_stream_snapshot_free(&snapshot->prev_snapshot); - if (snapshot->old_memarea != NULL) - memarea_unref(&snapshot->old_memarea); - i_free(snapshot); + if (snapshot->free != NULL) + snapshot->free(snapshot); + else { + if (snapshot->old_memarea != NULL) + memarea_unref(&snapshot->old_memarea); + i_free(snapshot); + } } static struct istream_snapshot * -- 2.47.3