From: Vladislav Shpilevoy via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: imeevma@tarantool.org Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH v1 2/3] sql: refactor sql_vdbe_mem_encode_tuple() Date: Sat, 20 Nov 2021 00:35:46 +0100 [thread overview] Message-ID: <bb97c94d-b8cb-bb15-0402-1e6d4eaad9cb@tarantool.org> (raw) In-Reply-To: <5c49fd526a5fcf59c4d8b1d222016dc3c08f35c7.1637159909.git.imeevma@gmail.com> Hi! Thanks for the patch! > diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c > index 356b2c7be..2ba4135b0 100644 > --- a/src/box/sql/mem.c > +++ b/src/box/sql/mem.c > @@ -3013,31 +3013,31 @@ mem_to_mpstream(const struct Mem *var, struct mpstream *stream) > } > > char * > -sql_vdbe_mem_encode_tuple(struct Mem *fields, uint32_t field_count, > - uint32_t *tuple_size, struct region *region) > +mem_encode_array(const struct Mem *mems, uint32_t count, uint32_t *size, > + struct region *region) > { > size_t used = region_used(region); > bool is_error = false; > struct mpstream stream; > mpstream_init(&stream, region, region_reserve_cb, region_alloc_cb, > set_encode_error, &is_error); > - mpstream_encode_array(&stream, field_count); > - for (struct Mem *field = fields; field < fields + field_count; field++) > - mem_to_mpstream(field, &stream); > + mpstream_encode_array(&stream, count); > + for (const struct Mem *mem = mems; mem < mems + count; mem++) > + mem_to_mpstream(mem, &stream); > mpstream_flush(&stream); > if (is_error) { If some memory was allocated/reserved before mpstream_flush() failed (inside of mem_to_mpstream()), then the region might leak. I would recommend to add a truncate here. > diag_set(OutOfMemory, stream.pos - stream.buf, > "mpstream_flush", "stream"); > return NULL; > }
next prev parent reply other threads:[~2021-11-19 23:35 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-11-17 14:40 [Tarantool-patches] [PATCH v1 0/3] Introduce syntax for ARRAY values Mergen Imeev via Tarantool-patches 2021-11-17 14:41 ` [Tarantool-patches] [PATCH v1 1/3] sql: change mpstream_encode_vdbe_mem() signature Mergen Imeev via Tarantool-patches 2021-11-17 14:41 ` [Tarantool-patches] [PATCH v1 2/3] sql: refactor sql_vdbe_mem_encode_tuple() Mergen Imeev via Tarantool-patches 2021-11-19 23:35 ` Vladislav Shpilevoy via Tarantool-patches [this message] 2021-11-24 7:24 ` Mergen Imeev via Tarantool-patches 2021-11-17 14:41 ` [Tarantool-patches] [PATCH v1 3/3] sql: introduce syntax for ARRAY values Mergen Imeev via Tarantool-patches 2021-11-19 23:36 ` Vladislav Shpilevoy via Tarantool-patches 2021-11-24 7:29 ` Mergen Imeev via Tarantool-patches 2021-11-29 23:06 ` [Tarantool-patches] [PATCH v1 0/3] Introduce " Vladislav Shpilevoy via Tarantool-patches 2021-11-30 8:43 Mergen Imeev via Tarantool-patches 2021-11-30 8:43 ` [Tarantool-patches] [PATCH v1 2/3] sql: refactor sql_vdbe_mem_encode_tuple() Mergen Imeev via Tarantool-patches
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bb97c94d-b8cb-bb15-0402-1e6d4eaad9cb@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=imeevma@tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v1 2/3] sql: refactor sql_vdbe_mem_encode_tuple()' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox