[tarantool-patches] Re: [PATCH] box: add tuple:size function
Konstantin Osipov
kostja at tarantool.org
Wed Oct 17 21:14:47 MSK 2018
* 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?
--
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