The larger the image size, the larger the memory allocated to alloca.
As far as I know, using alloca in a loop and
allocating a relatively large amount is not a good idea.
It is wrong that BUFFER_SIZE is 2k. I think it's fine if it's a small buffer as appropriate.
Probably 1~255. or half of width.
The crash problem is solved by a little bit more change.
But I will abandon this revision.
I think it is more efficient to reuse small buffer(avoid duplication)
than to do allocation memory every time.
But as you say, this change seems to be ineffective.