From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp48.i.mail.ru (smtp48.i.mail.ru [94.100.177.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 8ECE5469719 for ; Fri, 16 Oct 2020 01:30:30 +0300 (MSK) Date: Fri, 16 Oct 2020 01:30:50 +0300 From: Alexander Turenko Message-ID: <20201015223050.5cogmy2fxp4qwydo@tkn_work_nb> References: <1ce6ed8f564840da010fec4b937f4eeaf918e4db.1602634213.git.tsafin@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1ce6ed8f564840da010fec4b937f4eeaf918e4db.1602634213.git.tsafin@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH 1.10 v4 2/5] module api: export box_key_def_dup List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Timur Safin Cc: tarantool-patches@dev.tarantool.org, v.shpilevoy@tarantool.org > +static int > +test_key_def_dup(lua_State *L) > +{ > + box_key_def_t *key_def = NULL; > + box_key_part_def_t part; > + box_key_part_def_t *dump = NULL; > + uint32_t dump_part_count = 0; > + > + key_part_def_set_nondefault(&part); > + key_def = box_key_def_new_v2(&part, 1); > + assert(key_def != NULL); > + box_key_def_t *key_def_dup = box_key_def_dup(key_def); > + assert(key_def_dup != NULL); > + > + dump = box_key_def_dump_parts(key_def_dup, &dump_part_count); > + assert(dump != NULL); > + assert(dump_part_count == 1); > + > + key_part_def_check_equal(&part, &dump[0]); > + key_part_def_check_zeros(&dump[0]); key_part_def_check_zeros() is to verify how _dump_parts() works per se. It has no any connection with the duplicated key_def content. So I would left just key_part_def_check_equal() here. > + > + box_key_def_delete(key_def_dup); > + box_key_def_delete(key_def); The dumped parts are allocated on the box region. I would truncate the region at the end: | size_t region_svp = box_region_used(); | <...> | box_region_truncate(region_svp); May be ignored in a test, but I would do so just to highlight the proper usage of the API. If not us, who? > + > + lua_pushboolean(L, 1); > + return 1; > +} > +