[Tarantool-patches] [PATCH 4/5] decimal: introduce decimal_to_string

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Sun Aug 1 18:04:06 MSK 2021


Thanks for the review!

On 29.07.2021 13:52, Sergey Ostanevich wrote:
> Hi! Thanks for the patch, my 2 cents below. 
> 
> Otherwise - LGTM.
> 
> Regards,
> Sergos
> 
> 
>> On 28 Jul 2021, at 00:24, Vladislav Shpilevoy <v.shpilevoy at tarantool.org> wrote:
>>
>> It saves decimal as a string into an externally passed buffer.
> 
> Please mention decimal_to_string() introduction.

It is in the commit title already. I don't want to duplicate the title
in the message.

>> diff --git a/src/lib/core/decimal.c b/src/lib/core/decimal.c
>> index 4befbda37..6d2ccb96f 100644
>> --- a/src/lib/core/decimal.c
>> +++ b/src/lib/core/decimal.c
>> @@ -175,6 +175,14 @@ decimal_str(const decimal_t *dec)
>> 	return buf;
>> }
>>
>> +void
>> +decimal_to_string(const decimal_t *dec, char *str)
>> +{
>> +	char *tmp = decNumberToString(dec, str);
>> +	assert(str == tmp);
> 
> Why? The decToString() doesn't touch original string pointer, working on
> a local copy.

Yes, this is why there is the assertion. Also to be consistent with
decimal_str() which has the same assert.

>> +	(void)tmp;
>> +}


More information about the Tarantool-patches mailing list