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

Add option to create new instances of loaded libraries #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

malter
Copy link
Member

@malter malter commented Nov 14, 2024

No description provided.

@@ -133,6 +133,8 @@ namespace lib_manager {
string name = _lib->getLibName();

newLib.destroy = 0;
newLib.create = 0;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using 0 here, it would be better to use one of the following:

  • (void *)0
  • NULL
  • nullptr

LibInterface* LibManager::getNewInstance(const string &libName) {
if(libMap.find(libName) == libMap.end()) {
#ifdef DEBUF
fprintf(stderr, "LibManager: could not find \"%s\"\n", libName.c_str());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use std::cerr here. We are in C++ not in C.

return 0;
}
libStruct *theLib = &(libMap[libName]);
// todo: clear how to deal with the use count in this case
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you would use shared pointers, you would not need to reference count yourself.

@@ -45,6 +45,8 @@ namespace lib_manager {
struct libStruct {
LibInterface *libInterface;
destroyLib *destroy;
createLib *create;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend using safer/smart pointers instead of raw ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants