[prev in list] [next in list] [prev in thread] [next in thread]
List: kfm-devel
Subject: Re: Pointer to reference to QChar? (Was: Re: CSSMediaRule::insertRule)
From: Lars Knoll <knoll () kde ! org>
Date: 2001-09-25 15:24:33
[Download RAW message or body]
On Tuesday 25 September 2001 15:59, Martijn Klingens wrote:
> On Tuesday 25 September 2001 15:37, David Faure wrote:
> > Without knowing the code much, this looks very much like any parser
> > you'd write: there is a pointer to the current char being parsed,
> > and this pointer has to be passed by reference so that it gets updated
> > in the caller !
> > So the "workaround" is correct, assuming you have a single thing to parse
> > and that parseRule will do it all.
>
> Ooooooh... I never expected that the code would actually change the curP
> argument, since it is const.
>
> And here my C++ knowledge is a bit faint, probably...
>
> I expected 'const QChar * &' to be a non-const pointer to a reference to a
> const QChar. In that case the reference would be pointless as it would be
> referencing const data. But I probably was wrong there...
It's a reference to a (onst QChar *). const QChar * means a pointer to a
const QChar, so you're not allowed to change the contents of the parsed
string, but you can still change the const QChar the pointer is pointing to.
If you want a pointer you can't change, you'll have to use "const QChar *
const".
> Anyway, I can now assume my workaround is sane and continue with my other
> problems. I hope to have a patch ready for review before I return home
> today.
It is. I just didn't look close enough. The old code would have given you
some memory corruption at some point.
Cheers,
Lars
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic