Re: [evolution-patches] Fix for bug#306986
- From: jeff cai <Jeff Cai Sun COM>
- To: Sankar P <psankar novell com>
- Cc: Rohini <srohini novell com>, evolution-patches gnome org
- Subject: Re: [evolution-patches] Fix for bug#306986
- Date: Mon, 19 Dec 2005 18:28:13 +0800
On Mon, 2005-12-19 at 15:12 +0530, Sankar P wrote:
> Hi,
>
> >
> > +static void
> > +html_engine_strip_quote(gchar *word)
> > +{
> > + if(word[0]=='\'' && word[strlen(word)-1]=='\'') {
> > + int i;
> > +
> > + for(i=1;i<strlen(word)-1;i++)
> > + word[i-1]=word[i];
> > + word[strlen(word)-2]='\0';
> > + }
> > +}
> >
>
> strlen(word) can be saved in some temporary variable so as to avoid
> these many function calls.
>
> The declaration of i can be moved outside the if-loop. (Compiler might
> do it, while optimizing)
>
> This makes a string <<'word'\0>> to <<word\0'\0>>
>
> Wont this be leaking memory when we issue the g_free by passing the
> base-address of the string, Since char beyond \0 (the apostophe) wont be
> freed at all?
I think there is no problem when you call g_free with the base-address
of the string. For OS, memory decollatrion doesn't consider the data
in that memory.
>
> An alternative approach will be:
>
> fn() {
>
> int n;
> n = strlen(word);
> if(word[0]=='\'' && word[n-1]=='\'') {
> word[0]=word[n-1]=' ';
> g_strstrip(word);
> }
> }
>
> so that the movement of characters will be internally taken care by GLib
> in an efficient manner using g_memmove.
>
> On Mon, 2005-12-19 at 14:25 +0530, Rohini wrote:
> > Hi
> >
> > I have attached the fix for bug#306986: Adding new word (enclosed in
> > single quotes) to dictionary does not work
> >
> > Thanks,
> > Rohini
> > _______________________________________________
> > Evolution-patches mailing list
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]