Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AxPluginAPI Plugin List Redesign #2

Open
mdeforge opened this issue Feb 1, 2022 · 0 comments
Open

AxPluginAPI Plugin List Redesign #2

mdeforge opened this issue Feb 1, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@mdeforge
Copy link
Contributor

mdeforge commented Feb 1, 2022

The current AxPluginAPI design for returning a list of plugins is not ideal. Ideally I would have a function that returns a pointer to the array of plugins (in this case, currently an AxArray) that I could then iterate to retrieve a pointer to each AxPlugin.

This is currently not possible due how the data is organized in Plugin.c. AxHashTable doesn't currently (and maybe never will) actually store the data. It just stores void pointers to data. Instead, the data is allocated via an AxArray and then HashTable stores pointers to its elements.

There is a lot wrong with this design, chief among them is the memory management dance that needs to happen if that AxArray ever gets reallocated. But, even as a temporary solution it has it's problems. If I wanted to return a pointer to the AxArray and then index through it, I must move my AxPlugin structure to the header. You can't iterate through an array of an opaque data type since the size of the data type is not known. If I had an array of pointers I could, but the data is not currently stored that way.

One last complaint. I hate having to pass a buffer and a size into functions. I also strongly dislike mallocing in a function and then leaving it up the caller to remember to free. If I had a temp allocator, I could allocate the string on it and return that and let the allocator manage the lifetime. Food for thought.

@mdeforge mdeforge added the enhancement New feature or request label Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant