From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 9340274145; Tue, 5 Oct 2021 00:52:51 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9340274145 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1633384371; bh=ocrrk9bzjJOwmIQxXA4qqhhyhC0lbsAtyoeiYJNQj5Q=; h=To:Cc:References:Date:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=TqDZUAzhvY4xibuBoL3uOeBqTIcB4cYUTqyyu8CAmdeXfD3kqh/KbgZbE+KY2HyNj KcZz2xXJSkToi6qqVFRssUe/8yjvN9LJFh2i2vMYQKfeBe2+roEjaaeL2bQ0uKX/TZ IlgvWxTAeo4bWuYe6HXi0K3I6NkgtBB4Ci8G15tA= Received: from smtpng1.i.mail.ru (smtpng1.i.mail.ru [94.100.181.251]) (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 556A16FCBF for ; Tue, 5 Oct 2021 00:52:45 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 556A16FCBF Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1mXVt6-0007Xf-Jw; Tue, 05 Oct 2021 00:52:45 +0300 To: imeevma@tarantool.org Cc: tarantool-patches@dev.tarantool.org References: Message-ID: <7447231b-f112-5228-ebaa-40a93f62aefa@tarantool.org> Date: Mon, 4 Oct 2021 23:52:43 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9064ADF4728AA0EE9B46A983E38D3F2FC9543D0F0079D7838182A05F538085040E88EDF43D975D140FF00C2052CE60D6CCB9DD59FCB49D86FB62BEC06AB39B1D4 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7A4C4638C9DDF45FCEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006376AFB9B40001E44068638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D86140275D5E53264A607A259BE7F361A9117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCE2CCD8F0CAA010FB389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC87BD21ED50D08CA4DF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA7E827F84554CEF5019E625A9149C048EE9ECD01F8117BC8BEE2021AF6380DFAD18AA50765F790063735872C767BF85DA227C277FBC8AE2E8BDCE939D40DBB93CA75ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458834459D11680B505C0B97CAE4A76F82F6797229772052B7C X-C1DE0DAB: 0D63561A33F958A503965B17988AC3F3B798F558BF31405702EB5CF4640D5144D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75B7BFB303F1C7DB4D8E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D342F9EE325F82A28A8799CF2147A867950B75261489BC553DEF34CA5F22E216120DA49ECB47FC0CB021D7E09C32AA3244CB626C6ABBB9E35A3C67F003FA2BFF2A0E8FBBEFAE1C4874C729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj+1ww+tpaZerYG/WYp/X1EA== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5DADAB0871029428A29927D57AF00AAFAC3841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v4 06/16] sql: introduce mem_append() X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Thanks for working on this! > diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c > index 079083fa1..b8ead8f41 100644 > --- a/src/box/sql/mem.c > +++ b/src/box/sql/mem.c > @@ -1925,6 +1925,27 @@ mem_move(struct Mem *to, struct Mem *from) > from->zMalloc = NULL; > } > > +int > +mem_append(struct Mem *mem, const char *value, uint32_t len) > +{ > + assert((mem->type & (MEM_TYPE_BIN | MEM_TYPE_STR)) != 0); > + if (len == 0) > + return 0; > + int new_size = mem->n + len; > + if (((mem->flags & (MEM_Static | MEM_Dyn | MEM_Ephem)) != 0) || > + mem->szMalloc < new_size) { > + /* > + * Force exponential buffer size growth to avoid having to call > + * this routine too often. > + */ > + if (sqlVdbeMemGrow(mem, new_size + mem->n, 1) != 0) Looks like you could call sqlVdbeMemGrow() without all these checks above. The grow function does them already. > + return -1; > + } > + memcpy(&mem->z[mem->n], value, len); > + mem->n = new_size; > + return 0; > +}