Page 1 of 1
Is it safe to call UseZipPacker more than once?
Posted: Sun Aug 14, 2016 4:40 am
by Karig
I'm thinking of writing a PureBasic module for reading DOCX files. Since a DOCX file is really a ZIP file, I'd call UseZipPacker() before reading the file.
My question is: If I want to write another module in the same program that also accesses some kind of ZIP file, is it safe for that other module to call UseZipPacker() a second time, or will that waste resources?
Re: Is it safe to call UseZipPacker more than once?
Posted: Sun Aug 14, 2016 7:16 am
by Shield
Yeah, to my knowledge it is completely save to do that as these UseXXX() functions are mainly used to
trigger linking with all the library functions.
Re: Is it safe to call UseZipPacker more than once?
Posted: Sun Aug 14, 2016 11:00 pm
by Lunasole
Yes, it is safe. And be sure that this is one of the very minor questions you should care about when writing something more or less complex in PB ^^
Btw, if you deal successfully with DOCX, maybe you have some ideas about XLS/XSLX? I didn't find any way to read/save them, except one depending on MS components.
Re: Is it safe to call UseZipPacker more than once?
Posted: Mon Aug 15, 2016 4:48 am
by Keya
Another way to check confirmation is just check the resulting executables with both one vs two instances of the UseXxxCodec() as they should be the same size if it's ok to use twice, which is indeed the case with UseZip. I think internally such functions use runtime defined constants (IF DEF...) to prevent multiple inclusion, although interestingly there's a small section of about 40 or so bytes that change!