[PATCH] ndr: use resized array for ndr tokens

Douglas Bagnall douglas.bagnall at catalyst.net.nz
Sat Feb 25 02:49:07 UTC 2017


I wrote:
> OK, I see what you and Volker mean about talloc_array_length().
> 
> On 24/02/17 21:09, Stefan Metzmacher wrote:
>> Hi Douglas,
>>
>> I think if we want, we can keep that ABI.
>>
>> We could change
>>
>> struct ndr_token_list {
>> 	struct ndr_token_list *prev, *next;
>> };
>>
>> into
>>
>> struct ndr_token_list {
>> 	struct ndr_token_list *array, *next_free;
>> };
>>
>> The 'count' can calculated as
>>
>> if (list->next_free != NULL) {
>> 	count = some pointer diff magic
>> } else {
>> 	count = talloc_array_length()
>> }
> 
> Yes, though there would be some slightly horrible casting involved.

Like this. It's (arguably) not too bad. No pointer diff magic is
needed because there is an unused uint32_t hanging around.

Douglas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ndr-Use-resizing-array-instead-of-linked-lists.patch
Type: text/x-diff
Size: 8366 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20170225/3557545e/0001-ndr-Use-resizing-array-instead-of-linked-lists.diff>


More information about the samba-technical mailing list