You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: