[tarantool-patches] Re: [PATCH] box: add tuple:size function
Alexander Turenko
alexander.turenko at tarantool.org
Wed Oct 17 21:20:25 MSK 2018
On Wed, Oct 17, 2018 at 09:14:47PM +0300, Konstantin Osipov wrote:
> * Vladislav Shpilevoy <v.shpilevoy at tarantool.org> [18/10/17 21:12]:
>
> > Also, some people can use it right now to allocate a
> > buffer of a correct size before calling box_tuple_to_buf.
> > I understand, that box_tuple_to_buf(tuple, NULL, 0) returns
> > bsize as well, but some people could miss it, or just use
> > box_tuple_bsize because it looks better when you write like
> > this:
> >
> > size = box_tuple_bsize(tuple)
> > buf = alloc(size)
> > box_tuple_to_buf(tuple, buf, size)
> >
> > than like this:
> >
> > size = box_tuple_to_buf(tuple, NULL, 0) // <- difference
> > buf = alloc(size)
> > box_tuple_to_buf(tuple, buf, size)
> >
> > Even if we close eyes on the fact, that a user of
> > the first way will allocate more data than needed,
> > imagine, that then he does something like this:
> >
> > send(sockfd, buf, size)
> >
> > Now, he send some garbage uninitialized data of 14
> > bytes at the end of buf.
>
> Is there any known use?
>
https://github.com/search?p=1&q=box_tuple_bsize&type=Code
One seems to be the real (ok, more or less real) usage:
https://github.com/rtsisyk/tarantool-rust
> --
> Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
> http://tarantool.io - www.twitter.com/kostja_osipov
>
More information about the Tarantool-patches
mailing list