unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Jani Nikula <jani@nikula.org>
To: Tomi Ollila <tomi.ollila@iki.fi>,
	Vladimir Marek <Vladimir.Marek@Oracle.COM>
Cc: notmuch@notmuchmail.org, Vladimir Marek <vlmarek@volny.cz>
Subject: Re: [PATCH 01/24] lib/message.cc: stale pointer bug
Date: Thu, 02 May 2013 23:36:30 +0300	[thread overview]
Message-ID: <87mwsd3yr5.fsf@nikula.org> (raw)
In-Reply-To: <m238u5tg2f.fsf@guru.guru-group.fi>

On Thu, 02 May 2013, Tomi Ollila <tomi.ollila@iki.fi> wrote:
> On Thu, May 02 2013, Vladimir Marek <Vladimir.Marek@Oracle.COM> wrote:
>
>>> >      int prefix_len = strlen (prefix);
>>> > -    const char *term = NULL;
>>> > +    std::string term;
>>> >      char *value;
>>> >  
>>> >      i.skip_to (prefix);
>>> >  
>>> > -    if (i != end)
>>> > -	term = (*i).c_str ();
>>> > +    if (i == end)
>>> > +	return NULL;
>>> >  
>>> > -    if (!term || strncmp (term, prefix, prefix_len))
>>> > +    term = *i;
>>> 
>>> ... hmm, a raii(?) solution above would be std::string term = *i;
>>
>> I'm not sure what's raii (I'm not very good at c++ ...), but I guess you
>> mean to use 'std::string term = *i;' to avoid copy constructor. That
>> surely is a good idea. Let me rework the patch!
>
> I am not that smart (i.e. avoid copy constructor it might be, I don't
> know...) I am lousy in c++. I attempter to mean
> http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization
> in a sense that when variable is introduced it is also initialized
> to useful value (so that no-one accidentally add code between introduction
> and initialization). 
>  
> Anyway, if you rework the patch then we can vote which version to
> apply (yeah, sure >;)

I already dropped needs-review from the latest version [1]. I'm curious
about patches 2-24, let's not stall here. ;)

Jani.


[1] id:1367505102-12860-1-git-send-email-Vladimir.Marek@oracle.com

      reply	other threads:[~2013-05-02 20:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-01 21:33 [PATCH 01/24] lib/message.cc: stale pointer bug Vladimir.Marek
2013-05-01 21:43 ` Vladimir Marek
2013-05-02 10:01 ` Tomi Ollila
2013-05-02 13:45   ` Vladimir Marek
2013-05-02 18:03     ` Tomi Ollila
2013-05-02 20:36       ` Jani Nikula [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mwsd3yr5.fsf@nikula.org \
    --to=jani@nikula.org \
    --cc=Vladimir.Marek@Oracle.COM \
    --cc=notmuch@notmuchmail.org \
    --cc=tomi.ollila@iki.fi \
    --cc=vlmarek@volny.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).