From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Mon, 15 Oct 2018 20:52:41 +0300 From: Vladimir Davydov Subject: Re: [tarantool-patches] [PATCH v4 05/14] box: introduce tuple_format_sizeof routine Message-ID: <20181015175241.5zkrpkn5zftqmjfk@esperanza> References: <95a45583991d6285ea53d2c8b9a24571d2c8a848.1539244271.git.kshcherbatov@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <95a45583991d6285ea53d2c8b9a24571d2c8a848.1539244271.git.kshcherbatov@tarantool.org> To: Kirill Shcherbatov Cc: tarantool-patches@freelists.org List-ID: On Thu, Oct 11, 2018 at 10:58:50AM +0300, Kirill Shcherbatov wrote: > New tuple_format_sizeof routine calculates the size of memory > for tuple_format allocation. > > Part of #1012. > --- > src/box/tuple_format.c | 15 +++++++++++++-- > 1 file changed, 13 insertions(+), 2 deletions(-) > > diff --git a/src/box/tuple_format.c b/src/box/tuple_format.c > index d8acaa5..6a287f2 100644 > --- a/src/box/tuple_format.c > +++ b/src/box/tuple_format.c > @@ -42,6 +42,18 @@ static const struct tuple_field tuple_field_default = { > }; > > /** > + * Calculate the size of tuple format allocation. > + * @param field_count Count of tuple fields. > + * @retval Size of memory allocation. > + */ > +static inline uint32_t > +tuple_format_sizeof(uint32_t field_count) > +{ > + return sizeof(struct tuple_format) + > + field_count * sizeof(struct tuple_field); > +} I looked at patch 10. Without tuple_format_dup, which I'm planning to drop, this function wouldn't make much sense IMO.