This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [patch 1/3] Make obconcat use stdarg
- From: Tom Tromey <tromey at redhat dot com>
- To: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Fri, 30 Apr 2010 12:38:49 -0600
- Subject: Re: [patch 1/3] Make obconcat use stdarg
- References: <20100430181605.GA19190@host0.dyn.jankratochvil.net>
- Reply-to: tromey at redhat dot com
>>>>> "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