List:Internals« Previous MessageNext Message »
From:Michael Widenius Date:October 15 2009 4:19pm
Subject:Re: String:c_ptr makes me unhappy
View as plain text  

>>>>> "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

  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.

String:c_ptr makes me unhappyMARK CALLAGHAN14 Oct
  • re: String:c_ptr makes me unhappyMichael Widenius14 Oct
    • Re: String:c_ptr makes me unhappyMARK CALLAGHAN14 Oct
      • Re: String:c_ptr makes me unhappyMichael Widenius14 Oct
        • Re: String:c_ptr makes me unhappyKristian Nielsen15 Oct
          • Re: String:c_ptr makes me unhappyMichael Widenius15 Oct