buffer\datum questions

Olya olyasib12 at gmail.com
Thu Aug 2 09:54:34 CEST 2012

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()?


More information about the Gnutls-devel mailing list