From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 73D3F2CE92 for ; Wed, 17 Oct 2018 14:20:27 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZvU4l0HBYip6 for ; Wed, 17 Oct 2018 14:20:27 -0400 (EDT) Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 2F80C2CE8C for ; Wed, 17 Oct 2018 14:20:27 -0400 (EDT) Date: Wed, 17 Oct 2018 21:20:25 +0300 From: Alexander Turenko Subject: [tarantool-patches] Re: [PATCH] box: add tuple:size function Message-ID: <20181017182025.43hjuyankc3bcwm3@tkn_work_nb> References: <1538070923-23087-1-git-send-email-ivushkinalex@gmail.com> <20181016182144.GB5454@chai> <20181017072810.bxyfdrtq2rsxj5ub@tkn_work_nb> <20181017152949.GB19013@chai> <4f41a343-cd2a-44c3-06b8-3267db212b79@tarantool.org> <20181017181447.GC28587@chai> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20181017181447.GC28587@chai> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: Konstantin Osipov Cc: Vladislav Shpilevoy , tarantool-patches@freelists.org, Morgan-iv On Wed, Oct 17, 2018 at 09:14:47PM +0300, Konstantin Osipov wrote: > * Vladislav Shpilevoy [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 >