[ccan] Add new 'bytestring' module
David Gibson
david at gibson.dropbear.id.au
Mon May 21 19:02:41 EST 2012
On Sun, May 20, 2012 at 10:28:38PM -0500, Jonathan Nieder wrote:
> Hi,
>
> David Gibson wrote:
>
> > --- /dev/null
> > +++ b/ccan/bytestring/_info
> > @@ -0,0 +1,36 @@
> [...]
> > + * Because of this use case, the bytestrings are treated as having
> > + * immutable contents (we use a const char pointer). The caller code
> > + * is responsible for ensuring that the lifetime of the data
> > + * referenced by the bytestrings is long enough not to leave
> > + * bytestring structures with a dangling pointer.
>
> Neat. So these are the "memory areas" that functions like memcpy and
> memmem manipulate, and as this library improves it might grow to
> include various examples of how to safely modify their content without
> buffer overflows.
Hrm. Maybe. What I have in mind for now is more for representing
slices from a larger buffer or string without having to do lots of
copies.
> For some reason when I heard the name bytestring it made me think of
> git's strbuf type --- a binary-safe growing buffer that always
> maintains a '\0' byte at the end:
I'm not entirely sold on the bytestring name either, but I haven't
come up with a better one.
[snip]
> Maybe some name like memarea would avoid ambiguity.
Maybe. I don't love 'memarea' either, though.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
More information about the ccan
mailing list