[PATCH] introduce CONFIG_BUFFER_SIZE()

Alexander Shishkin virtuoso at slind.org
Tue Jul 27 14:55:13 UTC 2010


On Tue, Jul 27, 2010 at 04:52:16 +0200, Bernhard Reutner-Fischer wrote:
> On Tue, Jul 27, 2010 at 05:21:58PM +0300, Alexander Shishkin wrote:
> >Since "sizeof buffer" won't work with dynamically allocated buffers,
> >and we still sometimes need to know the size of the whole buffer, we
> >need a way to always obtain said size.
> 
> I don't quite understand?
> You have these three:
> char b1[PROCPS_BUFSIZE]
> char b2[FILENAME_MAX]
> char b3[BUFSIZ]
> you
> RESERVE_CONFIG_BUFFER(b1, PROCPS_BUFSIZE)
> RESERVE_CONFIG_BUFFER(b2, FILENAME_MAX)
> RESERVE_CONFIG_BUFFER(b3, BUFSIZ)
> and
> RELEASE_CONFIG_BUFFER(b1)
> accordingly.
> 
> Where do you need "sizeof(PROCPS_BUFSIZE)" as opposed to
> "PROCPS_BUFSIZE", for example?

No, you might need sizeof(b1), as in

    fgets(b1, sizeof b1, ...)

for example.

Regards,
--
Alex


More information about the busybox mailing list