buffer\datum questions

Nikos Mavrogiannopoulos nmav at gnutls.org
Thu Aug 2 16:22:02 CEST 2012

On Thu, Aug 2, 2012 at 11:20 AM, Olya <olyasib12 at gmail.com> wrote:
> 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);

Looks good. However use I'd use the integer type for length.

> Or should we use "bool check" to make it more obvious?

Although we use many C99 features already the boolean type isn't one
of them. Let's keep int.

>> 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.

No problem to you use casts for that. Just make sure that the callee
doesn't modify that data.


More information about the Gnutls-devel mailing list