Hi!
>>>>> "Kristian" == Kristian Nielsen <knielsen@stripped>
> writes:
Kristian> Michael Widenius <monty@stripped> writes:
>> As far as I can remember, I haven't seen very, very few bugs in the
>> way String is used in MySQL becasue of c_ptr().
Kristian> I think I have seen several bugs with this, where the buffer was allocated
> too
Kristian> short, so there was no room for the trailing '\n'.
Kristian> That also seems a good argument for not just eliminating all Valgrind
> warnings
Kristian> on this.
Kristian> In any case, I agree with Mark that this is a case where the code is too
Kristian> subtle, and very easy for developers to trip over.
Yes, I agree.
For the future, I would like to suggest two ways to go forward:
- Get rid of all \0 terminated strings that we can get rid of.
- Change to use c_ptr_safe() instead of c_ptr()
- Benchmark to see the effects if we change c_ptr() to behave like
c_ptr_safe().
For this last thing to be done, I would however like to add a bit to
the String definition so that one can specify that the String has a
\0 termination. This should only be used when initializing a string
from a C constant string. If we do this, we should be able to do
the last change with very little speed loss.
Regards,
Monty