[BusyBox] remove type for RESERVE_BB_BUFFER defines
Mark Whitley
markw at lineo.com
Tue Mar 6 23:01:32 UTC 2001
On Tue, Mar 06, 2001 at 11:10:54PM +1100, Glenn McGrath wrote:
> Currently the reserve buffers defines only has type char and unsigned
> char.
>
> #ifdef BB_FEATURE_BUFFERS_GO_ON_STACK
> #define RESERVE_BB_BUFFER(buffer,len) char buffer[len]
> #define RESERVE_BB_UBUFFER(buffer,len) unsigned char buffer[len]
> #else
> #define RESERVE_BB_BUFFER(buffer,len) char
> *buffer=xmalloc(len)
> #define RESERVE_BB_UBUFFER(buffer,len) unsigned char
> *buffer=xmalloc(len)
> #endif
>
>
> If we took out the type we could make it
> #ifdef BB_FEATURE_BUFFERS_GO_ON_STACK
> #define RESERVE_BB_BUFFER(buffer,len) char buffer[len]
> #else
> #define RESERVE_BB_BUFFER(buffer,len) *buffer=xmalloc(len)
> #endif
>
> Then if we want to define an array of unsigned chars we could do.
>
> RESERVE_BB_BUFFER((unsigned char) buffer,len);
>
> Or if we want to define an array of unsigned long long we could do
>
> RESERVE_BB_BUFFER((unsigned long long) buffer, len * sizeof(unsigned
> long long));
>
> I cant see how the current setup could be used to define an array on
> non-chars without doing a cast in a seperate statement.
>
> Do these changes make sense ?
Yes, it does make sense. It might even make more sense to include a third arg
to the RESERVE_BB_BUFFER() macro that takes the data type.
If you want to code up a patch and post it to the list, I'll take a look at
it, test that it applies cleanly, etc.
Mark Whitley
markw at lineo.com
More information about the busybox
mailing list