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

Fix memory managemet issue in pointer to settings structure #4

Merged
merged 1 commit into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions RISTNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ bool RISTNetReceiver::initReceiver(std::vector<std::string> &rURLList,
// Default log settings
rist_logging_settings* lSettingsPtr = rSettings.mLogSetting.get();
lStatus = rist_logging_set(&lSettingsPtr, rSettings.mLogLevel, nullptr, nullptr, nullptr, stderr);
mLoggingScope.reset(lSettingsPtr);
if (lStatus) {
LOGGER(true, LOGG_ERROR, "rist_logging_set failed.")
return false;
Expand Down Expand Up @@ -556,7 +555,6 @@ bool RISTNetSender::initSender(std::vector<std::tuple<std::string,int>> &rPeerLi
// Default log settings
rist_logging_settings* lSettingsPtr = rSettings.mLogSetting.get();
lStatus = rist_logging_set(&lSettingsPtr, rSettings.mLogLevel, nullptr, nullptr, nullptr, stderr);
mLoggingScope.reset(lSettingsPtr);
if (lStatus) {
LOGGER(true, LOGG_ERROR, "rist_logging_set failed.")
return false;
Expand Down
14 changes: 4 additions & 10 deletions RISTNet.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ class RISTNetReceiver {
mPeerConfig.max_retries = RIST_DEFAULT_MAX_RETRIES;
mPeerConfig.weight = 5;
mPeerConfig.session_timeout = RIST_DEFAULT_SESSION_TIMEOUT;
mLogSetting = std::make_shared<rist_logging_settings>(rist_logging_settings LOGGING_SETTINGS_INITIALIZER);
mLogSetting = std::make_unique<rist_logging_settings>(rist_logging_settings LOGGING_SETTINGS_INITIALIZER);
}
rist_profile mProfile = RIST_PROFILE_MAIN;
rist_peer_config mPeerConfig;

rist_log_level mLogLevel = RIST_LOG_ERROR;
std::shared_ptr<rist_logging_settings> mLogSetting;
std::unique_ptr<rist_logging_settings> mLogSetting;
std::string mPSK;
std::string mCNAME;
int mSessionTimeout = 5000;
Expand Down Expand Up @@ -280,9 +280,6 @@ class RISTNetReceiver {

// The list of connected clients
std::map<rist_peer *, std::shared_ptr<NetworkConnection>> mClientListReceiver;

std::unique_ptr<rist_logging_settings, decltype(&free)> mLoggingScope{nullptr, &free};

};

//---------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -335,13 +332,13 @@ class RISTNetSender {
mPeerConfig.max_retries = RIST_DEFAULT_MAX_RETRIES;
mPeerConfig.weight = 5;
mPeerConfig.session_timeout = RIST_DEFAULT_SESSION_TIMEOUT;
mLogSetting = std::make_shared<rist_logging_settings>(rist_logging_settings LOGGING_SETTINGS_INITIALIZER);
mLogSetting = std::make_unique<rist_logging_settings>(rist_logging_settings LOGGING_SETTINGS_INITIALIZER);
};
rist_profile mProfile = RIST_PROFILE_MAIN;
rist_peer_config mPeerConfig;

rist_log_level mLogLevel = RIST_LOG_ERROR;
std::shared_ptr<rist_logging_settings> mLogSetting;
std::unique_ptr<rist_logging_settings> mLogSetting;
std::string mPSK;
std::string mCNAME;
uint32_t mSessionTimeout = 5000;
Expand Down Expand Up @@ -506,9 +503,6 @@ class RISTNetSender {

// The list of connected clients
std::map<rist_peer *, std::shared_ptr<NetworkConnection>> mClientListSender;

std::unique_ptr<rist_logging_settings, decltype(&free)> mLoggingScope{nullptr, &free};

};

#endif //CPPRISTWRAPPER__RISTNET_H