From 830f7eb9314159717318d43a1e4ad3068b1868de Mon Sep 17 00:00:00 2001 From: tt2468 Date: Thu, 18 Jan 2024 16:17:12 -0800 Subject: [PATCH] utils: Use BPtr for strings instead of manual bfree() --- src/utils/Obs_StringHelper.cpp | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/utils/Obs_StringHelper.cpp b/src/utils/Obs_StringHelper.cpp index e393941bc..fc541ec68 100644 --- a/src/utils/Obs_StringHelper.cpp +++ b/src/utils/Obs_StringHelper.cpp @@ -20,6 +20,8 @@ with this program. If not, see #include #include +#include + #include "Obs.h" #include "plugin-macros.generated.h" @@ -42,33 +44,29 @@ std::string Utils::Obs::StringHelper::GetObsVersion() std::string Utils::Obs::StringHelper::GetCurrentSceneCollection() { - char *sceneCollectionName = obs_frontend_get_current_scene_collection(); - std::string ret = sceneCollectionName; - bfree(sceneCollectionName); + BPtr sceneCollectionName = obs_frontend_get_current_scene_collection(); + std::string ret = sceneCollectionName.Get(); return ret; } std::string Utils::Obs::StringHelper::GetCurrentProfile() { - char *profileName = obs_frontend_get_current_profile(); - std::string ret = profileName; - bfree(profileName); + BPtr profileName = obs_frontend_get_current_profile(); + std::string ret = profileName.Get(); return ret; } std::string Utils::Obs::StringHelper::GetCurrentProfilePath() { - char *profilePath = obs_frontend_get_current_profile_path(); - std::string ret = profilePath; - bfree(profilePath); + BPtr profilePath = obs_frontend_get_current_profile_path(); + std::string ret = profilePath.Get(); return ret; } std::string Utils::Obs::StringHelper::GetCurrentRecordOutputPath() { - char *recordOutputPath = obs_frontend_get_current_record_output_path(); - std::string ret = recordOutputPath; - bfree(recordOutputPath); + BPtr recordOutputPath = obs_frontend_get_current_record_output_path(); + std::string ret = recordOutputPath.Get(); return ret; } @@ -94,17 +92,15 @@ std::string Utils::Obs::StringHelper::GetLastRecordFileName() std::string Utils::Obs::StringHelper::GetLastReplayBufferFileName() { - char *replayBufferPath = obs_frontend_get_last_replay(); - std::string ret = replayBufferPath; - bfree(replayBufferPath); + BPtr replayBufferPath = obs_frontend_get_last_replay(); + std::string ret = replayBufferPath.Get(); return ret; } std::string Utils::Obs::StringHelper::GetLastScreenshotFileName() { - char *screenshotPath = obs_frontend_get_last_screenshot(); - std::string ret = screenshotPath; - bfree(screenshotPath); + BPtr screenshotPath = obs_frontend_get_last_screenshot(); + std::string ret = screenshotPath.Get(); return ret; }