From: Timo Sirainen Date: Thu, 17 Jun 2021 16:55:56 +0000 (+0300) Subject: lib: Add istream_snapshot.free() to allow more complex snapshots X-Git-Tag: 2.3.17~340 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=25e0619c01a0373dffc237cc95ee37d90fe0ff01;p=thirdparty%2Fdovecot%2Fcore.git lib: Add istream_snapshot.free() to allow more complex snapshots --- 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 *