speechd-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Add a portable implementation of getline to src/common.


From: Boris Dusek
Subject: [PATCH] Add a portable implementation of getline to src/common.
Date: Tue, 28 Sep 2010 18:28:45 +0200

Hello Chris,

On Sep 28, 2010, at 4:51 PM, Christopher Brannon wrote:

> +ssize_t spd_getline(char **lineptr, size_t * n, FILE * f);

I would add a doc comment before the function to stress the difference between
POSIX getline and this spd_getline - something like this:

/* `*lineptr' must be a valid argument that could be passed to the `g_free()'
 * glib function, i.e. it must be g_malloc'ed, not malloc'ed.
 */

> +   * For each iteration of this loop, the following holds.
> +   * There are buf_pos characters in the buffer.

please specify if buf_pos is including or excluding the 0 character.

> When we read another
> +   * character, we want to store it, and we also need enough
> +   * room for a NUL.

maybe better spelled as `null' (and without capitals, since
it does not have anything to do with the pointer constant NULL).

> -    ret = getline(&cmd_buf, &n, stdin);
> +    ret = spd_getline(&cmd_buf, &n, stdin);

since getline and spd_getline require different allocation functions for the
first parameter, and getline gets simply replaced by spd_getline, then either
the old code was wrong, or the new code is wrong, or first parameter is pointer
to NULL (and the code both was and is correct). In this particular case, first
parameter was NULL, but did you check the other changes from getline to
spd_getline for allocation consistency?

Otherwise thanks for this patch, I was just thinking of doing the same as part
of the Mac OS X port.

Boris


reply via email to

[Prev in Thread] Current Thread [Next in Thread]