-
-
Notifications
You must be signed in to change notification settings - Fork 849
fix(vendor/zlib) Updated zlib version and fixed function signature error #5650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Maintainers: The library was cross compiled from Linux. I would recommend building it again from windows as the file size dropped by 22% which seems odd. Here is a short script for testing the library: package main
import "vendor:zlib"
import "core:fmt"
//see https://gist.github.com/arq5x/5315739
main :: proc(){
// original string len = 36
text := cstring("Hello Hello Hello Hello Hello Hello!")
// placeholder for the compressed (deflated) version of "text"
deflated: [50]zlib.Byte
// // placeholder for the UNcompressed (inflated) version of "defalted"
inflated: [50]zlib.Byte
fmt.printfln("Uncompressed size is: %d", len(text));
fmt.printfln("Uncompressed size is: %s", text);
fmt.printfln("----------");
defstream:zlib.z_stream
defstream.zfree = nil
defstream.zalloc = nil
defstream.opaque = nil
defstream.avail_in = cast(zlib.uInt) len(text)+1 // Text + Terminator
defstream.next_in = cast(^zlib.Bytef) text
defstream.avail_out = cast(zlib.uInt) size_of(deflated) // size of output
defstream.next_out = cast(^zlib.Bytef) &deflated
// the actual compression work.
zlib.deflateInit(&defstream, zlib.BEST_COMPRESSION);
zlib.deflate(&defstream, zlib.FINISH);
zlib.deflateEnd(&defstream);
deflated_string := cstring(raw_data(deflated[:defstream.total_out]))
fmt.printfln("Deflated size is: %d", len(deflated_string));
fmt.printfln("Deflated text is: %s", deflated_string);
fmt.printfln("----------");
infstream:zlib.z_stream
infstream.zfree = nil
infstream.zalloc = nil
infstream.opaque = nil
infstream.avail_in = cast(zlib.uInt) defstream.total_out
infstream.next_in = cast(^zlib.Bytef) &deflated
infstream.avail_out = cast(zlib.uInt) size_of(inflated)
infstream.next_out = cast(^zlib.Bytef) &inflated
zlib.inflateInit(&infstream);
zlib.inflate(&infstream, zlib.NO_FLUSH);
zlib.inflateEnd(&infstream);
inflated_string := cstring(raw_data(inflated[:infstream.total_out]))
fmt.printfln("Inflated size is: %d", len(inflated_string));
fmt.printfln("Inflated text is: %s", inflated_string);
assert(inflated_string == text)
}Expected Output: Uncompressed size is: 36
Uncompressed size is: Hello Hello Hello Hello Hello Hello!
----------
Deflated size is: 13
Deflated text is: x��H���W��G*2
----------
Inflated size is: 36
Inflated text is: Hello Hello Hello Hello Hello Hello! |
| Version :: proc() -> cstring --- | ||
| @(link_prefix = "zlib") | ||
| Version :: proc() -> cstring --- | ||
|
|
||
| deflate :: proc(strm: z_streamp, flush: c.int) -> c.int --- | ||
| deflateEnd :: proc(strm: z_streamp) -> c.int --- | ||
| inflate :: proc(strm: z_streamp, flush: c.int) -> c.int --- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have you changed all of the formatting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have you changed all of the formatting?
Yeah..Sorry my mistake...happened due to odinfmt or emacs format buffer -.-
I will upload version soon.
Btw. are there any formatting guidelines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Fixes #5649
inflateInit_+inflateInithelper function