From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Wed, 3 Apr 2019 19:30:02 +0300 From: Vladimir Davydov Subject: Re: [PATCH v3 6/7] box: introduce field_map_builder class Message-ID: <20190403163002.2elldsqc777svhmw@esperanza> References: <51bd24d2df81ae0838dd74c96d35171b7824261e.1554218695.git.kshcherbatov@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <51bd24d2df81ae0838dd74c96d35171b7824261e.1554218695.git.kshcherbatov@tarantool.org> To: Kirill Shcherbatov Cc: tarantool-patches@freelists.org List-ID: On Tue, Apr 02, 2019 at 06:49:37PM +0300, Kirill Shcherbatov wrote: > +/** > + * Set data offset for a field identified by unique offset_slot. > + * > + * The offset_slot argument must be negative and offset must be > + * positive (by definition). > + */ > +static inline void > +field_map_builder_set_slot(struct field_map_builder *builder, > + int32_t offset_slot, uint32_t offset) > +{ > + assert(offset_slot < 0); > + assert(offset > 0); An assertion making sure that the offset is within the map would be appreciated. > + builder->slots[offset_slot] = offset; > +} > @@ -126,11 +126,11 @@ tuple_validate_raw(struct tuple_format *format, const char *tuple) > > struct region *region = &fiber()->gc; > size_t region_svp = region_used(region); > - uint32_t *field_map, field_map_size; > - int rc = tuple_field_map_create(format, tuple, true, &field_map, > - &field_map_size); > - assert(rc != 0 || field_map_size == format->field_map_size); > + struct field_map_builder builder; > + int rc = tuple_field_map_create(&builder, format, tuple, true); > region_truncate(region, region_svp); > + assert(rc != 0 || > + field_map_build_size(&builder) == format->field_map_size); This assertion is rather pointless after the next patch, where you replace '==' with '>='. Please remove. > return rc; > }