From: David Allsopp <dra-news@metastack.com>
To: "caml-list@inria.fr" <caml-list@inria.fr>
Cc: Dhek Uir <dhekuir@gmail.com>, Drup <drupyog+caml@zoho.com>
Subject: RE: [Caml-list] Simple compression library
Date: Mon, 2 Feb 2015 17:38:27 +0000 [thread overview]
Message-ID: <E51C5B015DBD1348A1D85763337FB6D9E98B2CBF@Remus.metastack.local> (raw)
In-Reply-To: <CAJn4uc4RdwLnABxwydi0O628NHeKrBfi5QZGmS=SwXZaR1_0TQ@mail.gmail.com>
Dhek Uir wrote:
> But since camlzip does not have an input_value function, it seems I must set up
> a buffer to decompress the data, then use Marshal to obtain input data from the
> decompressed buffer. But if I use Marshal.from_string to read the decompressed
> buffer, then I need to keep track of its position (which is not returned by
> Marshal.from_string), and check whether the buffer is nearly empty, so that I
> may need to re-read from the compressed in_channel, etc, etc. Did I miss the
> right function again?
Marshal has everything you need:
let input_value ch =
let header = String.create Marshal.header_size
in
Gzip.really_input ch header 0 Marshal.header_size;
let buffer = String.create (Marshal.total_size header 0)
in
Gzip.really_input ch buffer Marshal.header_size (Marshal.data_size header 0);
String.unsafe_blit header 0 buffer 0 Marshal.header_size;
Marshal.from_string buffer 0
David
next prev parent reply other threads:[~2015-02-02 17:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-02 15:39 Dhek Uir
2015-02-02 15:43 ` Jacques-Henri Jourdan
2015-02-02 16:05 ` Dhek Uir
2015-02-02 16:48 ` Drup
2015-02-02 17:00 ` Dhek Uir
2015-02-02 17:38 ` David Allsopp [this message]
2015-02-02 17:53 ` Dhek Uir
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E51C5B015DBD1348A1D85763337FB6D9E98B2CBF@Remus.metastack.local \
--to=dra-news@metastack.com \
--cc=caml-list@inria.fr \
--cc=dhekuir@gmail.com \
--cc=drupyog+caml@zoho.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox