Page 1 of 1

Adjustable Buffers, Number and Sizes

Posted: Fri May 10, 2019 11:43 am
by gray
I have several library modules that are basically application-independent, apart from the number of buffers and the buffer sizes. Arrays are easy and well performing data structures for buffers, but they are of a fixed size. For maintenance reasons, I would prefer to configure these library modules on a per-program basis, ie. not duplicate them per application with the number of buffers and their sizes adjusted accordingly.

I see two possibilities. 1) I can use using dynamic data structures using linked lists, which can be configured at start-up with an Init() call. But linked lists for an array-like fixed size buffer seems an overkill. 2) Or I extract the configuration constants into a configuration module, with a default config module right there with the library module, and the possibility to create an application-specific one in the folder of the main module.

Is there a third solution that I don't see?

Re: Adjustable Buffers, Number and Sizes

Posted: Fri May 10, 2019 12:51 pm
by cfbsoftware
I am not aware of any better solution. Option 2 is the way I would go. However, I would prefer to be consistent and always have a configuration module in the folder of the main module and not bother with a default config module. Then I could be sure which one is being used and be reminded if I forgot to supply it.

Re: Adjustable Buffers, Number and Sizes

Posted: Sat May 11, 2019 3:24 am
by gray
Thanks. Yes, agreed. Maybe a default config module can make sense for library modules that work without required configuration, but could be tweaked for specific cases, eg. the buffer sizes for a serial driver. But if config is required, there shouldn't be a default config module.