]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Add istream_snapshot.free() to allow more complex snapshots
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 17 Jun 2021 16:55:56 +0000 (19:55 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Tue, 6 Jul 2021 08:15:11 +0000 (08:15 +0000)
src/lib/istream-private.h
src/lib/istream.c

index ac31294859d30ff862466f5779d5bb63f7dd3959..c1180a57469bff6b0babd2a4d4ed63ef22f7ad80 100644 (file)
@@ -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 {
index 93c57034701b5d698629dcf3efd788ac3053032b..7c79e7dcf3e4c034c4003415ed0e342500ff0adc 100644 (file)
@@ -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 *