
Dear Sergei Shtylyov,
In message 4DBFF300.9010906@mvista.com you wrote:
Can we please keep the buffer on the stack as before?
It will be unsafe. We can't really predict the size of the buffer (unless
we postulate that the buffer size won't ever exceed e.g. 4K).
In which way will a buffer allocated on the stack be less safe than one allocated using malloc()? Changes to do things wrong (like forgetting to free the array on return or freeing a bad pointer) are much higher with malloc(), it seems.
I think using stack variables makes the code much more error prone, to the
point that U-Boot just crashes when the sector size happens to exceed our buffer size.
This statement makes no sense to me. Wether the sector size exceeds the buffer size or not is in no way dependent on where or how you allocate the buffer - be it on the stack or using malloc().
Umm... you _are_ aware that you can put dynamically sized arrays on the stack, aren't you?
Best regards,
Wolfgang Denk