[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: buffer\datum questions
From: |
Olya |
Subject: |
Re: buffer\datum questions |
Date: |
Thu, 02 Aug 2012 14:54:34 +0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 |
02.08.2012 14:37, Nikos Mavrogiannopoulos пишет:
>> _gnutls_buffer_pop_prefix (gnutls_buffer_st * buf, size_t * data_size, int
>> check) ?
>
> It reads a 32-bit integer from the buffer and checks whether the
> remaining data length are less than that.
So how exactly "int check" is used - boolean indicator whether to perform
remainder
length check or not?
Or it's the length value against which the remainder will be checked?
Are there similar functions for 16 bits? 8 bits? etc.
>> 2) Do I have to pre-allocate memory for the datum, copy my data to datum,
>> call
>> _replace() and deallocate datum? Could you give simple example of _replace()
>> usage?
>
> The replace, will copy the datum you provide (already allocated) to the
> buffer.
So the expected call sequence is:
_gnutls_set_datum (&dat, data, data_size);
_gnutls_buffer_replace_data (&buffer, &dat);
_gnutls_free_datum (&dat);
When I'm trying to do that I got segfault on _free_datum() due to double-free.
Could you provide proper example?
>> 3) When should I use _gnutls_buffer_reset() ?
>
> If you want to re-use a buffer. I.e. you appended some data, sent it
> to the peer, and want to use a new buffer. Instead of initializing a
> new one you reset that one.
So instead of _replace_data() I can call _reset() and _append()?
cheers,
Olga.