[BusyBox] coreutils/date.c buffer [PATCH]
Shaun Jackman
sjackman at gmail.com
Thu May 26 21:18:58 UTC 2005
On 3/8/05, Larry Doolittle <ldoolitt at recycle.lbl.gov> wrote:
> > + {
> > + /* Print OUTPUT (after ALL that!) */
> > + RESERVE_CONFIG_BUFFER(t_buff, 201);
> > + strftime(t_buff, 200, date_fmt, &tm_time);
> > + puts(t_buff);
> > +#ifdef CONFIG_FEATURE_CLEAN_UP
> > + RELEASE_CONFIG_BUFFER(t_buff);
> > +#endif
> > + }
>
> Shouldn't the RELEASE_CONFIG_BUFFER macro have the
> conditional on CONFIG_FEATURE_CLEAN_UP built-in?
My thought is no; my reasoning is that the BUFFER might be allocated
in an inner loop, in which case you'd want the buffer to be freed
regardless of the CLEAN_UP setting so that the inner loop does not run
out of memory. I suggest wrapping this into a new macro though:
CLEAN_UP_CONFIG_BUFFER which would call RELEASE_CONFIG_BUFFER if
CONFIG_FEATURE_CLEAN_UP is defined, and be a no-op if not defined.
I think this patch should be applied as is. A second patch should add
CLEAN_UP_CONFIG_BUFFER. Ack?
Cheers,
Shaun
More information about the busybox
mailing list