buffer\datum questions
Olya
olyasib12 at gmail.com
Thu Aug 2 11:20:49 CEST 2012
02.08.2012 15:10, Nikos Mavrogiannopoulos пишет:
>> Or it's the length value against which the remainder will be checked?
>> Are there similar functions for 16 bits? 8 bits? etc.
>
> No. But we can make this more general if you need it.
That would be great. How about:
_gnutls_buffer_pop_prefix (gnutls_buffer_st * buf, size_t * data_size, int check,
uint8_t pfx_len = 32);
Or should we use "bool check" to make it more obvious?
>>>> 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);
>
> Use set_datum() only if you want to copy(duplicate) the data you have
> into the datum. Otherwise just assign the values (datum->data,
> datum->size) to the needed one.
If I'm trying to use datum->data I've got to drop const qualifier from "const void *
data" parameter. Right now I'm not sure if I should copy data or not.
thanks,
Olga.
More information about the Gnutls-devel
mailing list