Re: [patch 1/3] Make obconcat use stdarg

Tom Tromey
2010-04-30T18:38:59Z

>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:

Jan> __attribute__ ((sentinel)) availability for gcc >= 4.0 I have copied from
Jan> <glib-2.0/glib/gmacros.h>. It roughly matches the GCC ChangeLog dates.

Jan> Still I find this patch as a code cleanup.

I agree.

Jan> +obconcat (struct obstack *obstackp, ...)
Jan> +{
Jan> + va_list ap;
Jan> + size_t len = 1;
Jan> + char *retval, *dest;
Jan> +
Jan> + va_start (ap, obstackp);
Jan> + for (;;)
Jan> + {
Jan> + const char *s = va_arg (ap, const char *);
Jan> +
Jan> + if (s == NULL)
Jan> + break;
Jan> + len += strlen (s);
Jan> + }
Jan> + va_end (ap);

I think it is better to just do the copying in a single loop.
Obstacks already handle growing objects well enough, there's no need to
work around this.

Personally I think this function would be better placed in util.c, but
that isn't a requirement for patch.

Tom