<<< Date Index >>>     <<< Thread Index >>>

Re: [PATCH] Mailbox Aliases



Hi,

* Bertrand Janin wrote:

[...]

> diff -r d213f3acdb68 buffy.c
> --- a/buffy.c Mon Jun 15 14:24:27 2009 -0700
> +++ b/buffy.c Tue Jun 16 23:04:04 2009 -0400

> +    /* Strip out alias for later */
> +    if ((p = strchr(buf, '=')) != NULL)
> +    {
> +      len = p - buf;
> +      alias = malloc(len + 1);
> +      strncpy(alias, buf, len);
> +      alias[len] = '\0';
> +      strcpy(tbuf, p + 1);
> +      strcpy(buf, tbuf);
> +    }

Mutt has quite a few library functions, so please use them. Especially 
safe_malloc() and the strfcpy() macro. Also see mutt_substrdup().

I also think you should check that *buf != '=' in case of typos like:

  mailboxes ==foo

> +    if (alias != NULL)
> +    {
> +      strcpy((*tmp)->alias, alias);
> +      free(alias);
> +    }

This can be done in one line using mutt_str_replace().

Rocco