On 7/9/25 17:44, 'Mark Rotteveel' via firebird-devel wrote:
> On 09/07/2025 16:31, 'Dimitry Sibiryakov' via firebird-devel wrote:
>> 'Mark Rotteveel' via firebird-devel wrote 09.07.2025 16:24:
>>> Given the Firebird string implementation already does
>>> nul-termination internally, is there a specific point to the
>>> `m_strings.append(1, '\0')` and including the nul-terminator of *ptr
>>> in the else branch?
>>
>> m_strings in this case is not a single string but a collection of
>> strings separated by <NUL> (and thus it is terminated by double null).
>> isc_arg_cstring is not guaranteed to be null-terminated so forcing
>> of the terminator is necessary to separate this (sub-)string from the
>> next one.
>> reserve() is just an optimisation to avoid double expansion of
>> storage.
>
> Is that documented somewhere in the code and I skipped over it?
>
Sooner of all not documented. At least when I was writing some status
vector parser for the first time I just looked at already existing parsers.
> That said, if m_strings is a collection, why isn't it something like
> std::vector or something?
>
Yes, certainly it was possible to use ObjectsArray<string>. But for a
set of typically short strings existing approach appeared to be more
efficient, first of all from RAM usage POV.