On Sat, 8 May 2021 at 17:50, Andrew Cagney <[email protected]> wrote:

>
>>
>>   extern pb_stream same_chunk_as_in_pbs(chunk_t chunk, const char *name);
>>
>
> It should be renamed to:
>
>   struct pbs_in chunk_as_pbs_in(chunk_t)
> or
>   struct pbs_in same_chunk_as_pbs_in(chunk_t)
>

I went through and updated the names.  Hopefully pbs_in and pbs_out are
used consistently.

The convention {same,clone}_<foo>_as_<blah>() came out of an earlier
discussion.  Because it was never really obvious if the handle being
returned was referring to the same or a clone of the buffer, it was spelt
out.

This buffer sharing is also why <blah>_from_<foo>() struggled.  For
addresses, functions are pure so:
    selector_from_address()
is pretty clear.  Not so when there's an underlying buffer.  While
technically shunk_from_pbs_out() has to return the same buffer (since a
shunk can't be freed it must be shared, right), chunk_from_pbs_out() feels
like it returned a clone ...., and chunk_for_pbs_out() makes me wonder if
I'm feeding the pbs chocolate chunk cookies.

On the bright side, it looks like same_pbs_out_as_chunk() can be eliminated.
_______________________________________________
Swan-dev mailing list
[email protected]
https://lists.libreswan.org/mailman/listinfo/swan-dev

Reply via email to