[Tarantool-patches] [PATCH v5 51/52] sql: introduce mem_get_bytes_len()

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Thu Apr 15 03:21:20 MSK 2021


Thanks for the patch!

> diff --git a/src/box/sql/mem.h b/src/box/sql/mem.h
> index e7612fe7e..a67345fbd 100644
> --- a/src/box/sql/mem.h
> +++ b/src/box/sql/mem.h
> @@ -870,6 +870,20 @@ mem_get_bin(const struct Mem *mem, const char **s);
>  int
>  mem_get_bytes_len(const struct Mem *mem, uint32_t *len);
>  
> +/**
> + * Return length of value for MEM of STRING or VARBINARY type. This function is
> + * not safe since there is no proper processing in case mem_get_bytes_len()
> + * return an error. In this case this function returns 0.
> + */
> +static inline int
> +mem_len_unsafe(const struct Mem *mem)
> +{
> +	uint32_t len;
> +	if (mem_get_bytes_len(mem, &len) != 0)

For the sake of consistency the safe function should be called
simply mem_len() IMO.

> +		return 0;
> +	return len;
> +}


More information about the Tarantool-patches mailing list