List Archive

Thread

Thread Index

Message

From: Andreas Falkenhahn <andreas%falkenhahn.com@localhost>
To: libzip mailing list <libzip-discuss%nih.at@localhost>
Subject: When to free zip_source?
Date: Tue, 31 Oct 2017 16:06:04 +0100

I want to add a file to a zip archive from custom data streamed in using
a callback source, like so:

        s = zip_source_function(arc->archive, my_zip_source_callback, userdata);
        zip_file_add(arc->archive, name, s, ZIP_FL_ENC_UTF_8);

Now when should I free "s"? I cannot do this right after zip_file_add() because
the source is still needed. So do I have to do it after

        zip_close(arc->archive);

?

Or are sources freed automatically when closing an archive? Or are they freed
automatically on ZIP_SOURCE_FREE? The documentation on ZIP_SOURCE_FREE says:

        ZIP_SOURCE_FREE: Clean up and free all resources, including `state`. The
                        callback function will not be called again.

What is meant by "state" here? Does this mean the source will be freed
automatically?

Tks

-- 
Best regards,
 Andreas Falkenhahn                          
mailto:andreas%falkenhahn.com@localhost

Made by MHonArc.