bebbo / libnix

libnix (v4): a C link library for AmigaOS/m68k
15 stars 9 forks source link

Libnix allocates 3x64kb for file buffers #62

Closed mheyer32 closed 2 years ago

mheyer32 commented 2 years ago

When using stdio, Libnix will allocate at least 3 64k chunks of buffers at program startup. Not that it matters much these days with everybody maxing out their Amigas, but there might be OS 1.3 users who disagree :-) I question if such large buffers are even overkill? Will this buffer size apply to each and every file one opens?

The buffers get allocated in initstdio.c https://github.com/bebbo/libnix/blob/master/sources/nix20/stdio/initstdio.c#L104 and use BUFSIZ as size.

bebbo commented 2 years ago

The value for BUFSIZ should normally be 256 KB, 512 KB or 4096 KB. This depends on the system and the compiler.

I increased it to 64K since it affects file I/O a lot... Well, the buffers for STDIN and STDERR could always be reduced to a few bytes. And fdopen could refer to an variable initialized with BUFSIZ, but you could provide your own variable with a different value.

mheyer32 commented 2 years ago

Thank you!