[notmuch] [PATCH] Add private implementations of strndup and getline.

Carl Worth cworth at cworth.org
Thu Nov 26 13:06:31 PST 2009


On Mon, 23 Nov 2009 07:43:30 -0600, "Jeffrey C. Ollie" <jeff at ocjtech.us> wrote:
> Add private implementations of strndup and getline for those platforms
> that don't have them (notably Mac OS X) no matter what preprocessor
> symbols you define.

Thanks. This is off to a very good start.

> +char *
> +_notmuch_strndup (const char *s, size_t n)
> +{
> +    size_t len = strlen (s);
> +    char *ret;
> +
> +    if (len <= n)
> +       return strdup (s);
> +
> +    ret = malloc(n + 1);

This needs to check and return NULL if malloc returns NULL.

> +/* getline implementation is copied from glibc. */

Then, this should have added a copyright attribution to the top of the
file.

In fact, everyone that's contributing non-trivial amounts should be
adding copyright statements. I don't mind too much if people consider
their own contributions to be insignificant enough to not merit a
copyright claim, but when copying code written by others, we definitely
need to bring the copyright attribution along.

Would also be good to mention the glibc version and license in this
comment and in the commit message as well.

-Carl


More information about the notmuch mailing list