On Jul 21, 2006, at 12:57 PM, Martin Mathieson wrote:
I think I wouldn't have created this bug in the first place if the
function
was instead called proto_tree_add_text_format(). I didn't realise
the last
arg was a format string - I'm used to those function names having the
_format suffix.
That might be a change worth making before 1.0; fortunately, it's
something that can be done mechanically.
The other (slightly) strange thing is that when the format string
(which is
supposed to be a const char*) was created by tvb_format_text() (which
returns a char*), I don't think my version of gcc showed a warning.
Passing a "char *" to a routine expecting a "const char *" is OK.
It's like lending your neighbor a piece of paper if
1) you don't care if your neighbor writes all over it
and
2) your neighbor only plans to use it as a sun shade.
I.e., since it's a "char *", it's OK to write over it, but the
routine you're passing it to is promising not to write over it, since
the formal argument is a "const char *".
It's the other way around that's a problem - passing a "const char
*", i.e. a string that's not supposed to be written on or destroyed
to a routine whose formal argument is a "char *", i.e. it makes no
promises that it won't write on it or destroy it.