This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


>>>>> "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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]