-
Notifications
You must be signed in to change notification settings - Fork 3
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
base: master
Are you sure you want to change the base?
Conversation
@@ -133,6 +133,8 @@ namespace lib_manager { | |||
string name = _lib->getLibName(); | |||
|
|||
newLib.destroy = 0; | |||
newLib.create = 0; |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
No description provided.