Adjustable Buffers, Number and Sizes

General discussions about working with the Astrobe IDE and programming ARM Cortex-M0, M3, M4 and M7 microcontrollers.
Post Reply
gray
Posts: 143
Joined: Tue Feb 12, 2019 2:59 am
Location: Mauritius

Adjustable Buffers, Number and Sizes

Post by gray » Fri May 10, 2019 11:43 am

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?

cfbsoftware
Site Admin
Posts: 525
Joined: Fri Dec 31, 2010 12:30 pm
Contact:

Re: Adjustable Buffers, Number and Sizes

Post by cfbsoftware » Fri May 10, 2019 12:51 pm

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.

gray
Posts: 143
Joined: Tue Feb 12, 2019 2:59 am
Location: Mauritius

Re: Adjustable Buffers, Number and Sizes

Post by gray » Sat May 11, 2019 3:24 am

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.

Post Reply