[Tarantool-patches] [PATCH v5 11/52] sql: introduce mem_destroy()
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Sun Apr 11 20:46:05 MSK 2021
Thanks for working on this!
See 3 comments below.
On 09.04.2021 19:36, Mergen Imeev via Tarantool-patches wrote:
> This patch introduces mem_destroy(). This function should be used to
> free and destroing all objects owned by MEM, if necessary.
1. "to free and destroy".
> Part of #5818
> ---
> diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c
> index 5135637d9..805dc7054 100644
> --- a/src/box/sql/mem.c
> +++ b/src/box/sql/mem.c
> @@ -92,6 +92,38 @@ mem_create(struct Mem *mem)
> +
> +void
> +mem_destroy(struct Mem *mem)
> +{
> + mem_clear(mem);
> + if (mem->szMalloc > 0)
> + sqlDbFree(mem->db, mem->zMalloc);
> + mem->n = 0;
> + mem->z = NULL;
> + mem->szMalloc = 0;
> + mem->zMalloc = NULL;
2. You could move szMalloc and zMalloc nullification under the 'if'
above.
> +}
> @@ -1384,7 +1359,7 @@ sqlValueFree(sql_value * v)
> {
> if (!v)
> return;
> - sqlVdbeMemRelease((Mem *) v);
> + mem_destroy((Mem *) v);
3. No need for whitespace after unary operators.
More information about the Tarantool-patches
mailing list