AmbiqAI / neuralSPOT

NeuralSPOT is Ambiq's AI SDK and Toolkit
https://ambiq.com
BSD 3-Clause "New" or "Revised" License
24 stars 6 forks source link

move state ownership from modules to application #37

Closed Jconn closed 1 year ago

Jconn commented 2 years ago

this PR is meant to change ownership of module state from the module to the application. This gives the application more control over memory management but does mean the application is responsible for not de-allocating these state variables.

I didn't make any changes to moving variables from global scope to static scope, but I can do that in another commit or another PR if wanted.

I haven't tested this change. A consequence of this change is application developers need to make sure not to de-allocate their module config structs (don't pass config structs declared on the stack into init functions)

carloshmorales commented 2 years ago

Do you plan to make example changes as part of this PR?

Jconn commented 2 years ago

Do you plan to make example changes as part of this PR?

oh yes I will do that - I forgot there were examples

Jconn commented 2 years ago

okay the two variables configs I changed are ns_audio_config_t and ns_rpc_config_t it looks like ns_audio_config_texamples were already declaring the config as global. ns_rpc_config_t configs have been moved from local to global scope in the examples. I haven't tested this code.