On 12/8/13 8:03 PM, Thiago Arruda wrote:
Hi
I'm writing a small program that reads messages from a stream. Before
each message, an integer will arrive specifying the size of the
following message.
I understand libuv will call my own function to allocate buffers with a
suggested size, but since I know the size of the incoming message, I
think it makes more sense to use that as the buffer size(Please correct
if my assumption is wrong, I'm not an expert C programmer).
What would be the 'pretty' way to handle this in libuv? I would rather
not use global variables to store the size of the next message.
Depends on what you'll do with that data, I guess. If you need to copy
it, then you may as well create a 64k statically allocated buffer and
reuse it every time.
If you want to use that number from the previous message for
preallocating the next buffer size, then you can create a structure of
your own to store that data and put it in the handle->data field.
Cheers,
--
Saúl Ibarra Corretgé
http://bettercallsaghul.com
--
You received this message because you are subscribed to the Google Groups
"libuv" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/libuv.
For more options, visit https://groups.google.com/groups/opt_out.