Elliott Hughes <address@hidden> wrote:
...
i like this partial factorization -- even though there's more stuff to
also come out -- because it's a meaningful chunk of functionality in
its own right, and deserves a name.
i'd rather see a function than a multi-line macro, though.
I prefer functions too, in general but I don't particularly like
the 6-parameter interface (and even less the 4-param one including
two in/out parameters -- it's bad enough that I've done that in
the macro). What did you have in mind?
The problem with the 4-parameter approach
static void
wrap_pattern (char *pattern, size_t *pattern_len,
char const *prefix, char const *suffix)
{
...
}
is that it works fine when we don't have to free the PATTERN,
but if anyone ever calls it with a malloc'd PATTERN, it will leak.