Skip to content

Commit 830f7eb

Browse files
committed
utils: Use BPtr for strings instead of manual bfree()
1 parent 5e3fff7 commit 830f7eb

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

src/utils/Obs_StringHelper.cpp

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ with this program. If not, see <https://www.gnu.org/licenses/>
2020
#include <inttypes.h>
2121
#include <QString>
2222

23+
#include <util/util.hpp>
24+
2325
#include "Obs.h"
2426
#include "plugin-macros.generated.h"
2527

@@ -42,33 +44,29 @@ std::string Utils::Obs::StringHelper::GetObsVersion()
4244

4345
std::string Utils::Obs::StringHelper::GetCurrentSceneCollection()
4446
{
45-
char *sceneCollectionName = obs_frontend_get_current_scene_collection();
46-
std::string ret = sceneCollectionName;
47-
bfree(sceneCollectionName);
47+
BPtr<char> sceneCollectionName = obs_frontend_get_current_scene_collection();
48+
std::string ret = sceneCollectionName.Get();
4849
return ret;
4950
}
5051

5152
std::string Utils::Obs::StringHelper::GetCurrentProfile()
5253
{
53-
char *profileName = obs_frontend_get_current_profile();
54-
std::string ret = profileName;
55-
bfree(profileName);
54+
BPtr<char> profileName = obs_frontend_get_current_profile();
55+
std::string ret = profileName.Get();
5656
return ret;
5757
}
5858

5959
std::string Utils::Obs::StringHelper::GetCurrentProfilePath()
6060
{
61-
char *profilePath = obs_frontend_get_current_profile_path();
62-
std::string ret = profilePath;
63-
bfree(profilePath);
61+
BPtr<char> profilePath = obs_frontend_get_current_profile_path();
62+
std::string ret = profilePath.Get();
6463
return ret;
6564
}
6665

6766
std::string Utils::Obs::StringHelper::GetCurrentRecordOutputPath()
6867
{
69-
char *recordOutputPath = obs_frontend_get_current_record_output_path();
70-
std::string ret = recordOutputPath;
71-
bfree(recordOutputPath);
68+
BPtr<char> recordOutputPath = obs_frontend_get_current_record_output_path();
69+
std::string ret = recordOutputPath.Get();
7270
return ret;
7371
}
7472

@@ -94,17 +92,15 @@ std::string Utils::Obs::StringHelper::GetLastRecordFileName()
9492

9593
std::string Utils::Obs::StringHelper::GetLastReplayBufferFileName()
9694
{
97-
char *replayBufferPath = obs_frontend_get_last_replay();
98-
std::string ret = replayBufferPath;
99-
bfree(replayBufferPath);
95+
BPtr<char> replayBufferPath = obs_frontend_get_last_replay();
96+
std::string ret = replayBufferPath.Get();
10097
return ret;
10198
}
10299

103100
std::string Utils::Obs::StringHelper::GetLastScreenshotFileName()
104101
{
105-
char *screenshotPath = obs_frontend_get_last_screenshot();
106-
std::string ret = screenshotPath;
107-
bfree(screenshotPath);
102+
BPtr<char> screenshotPath = obs_frontend_get_last_screenshot();
103+
std::string ret = screenshotPath.Get();
108104
return ret;
109105
}
110106

0 commit comments

Comments
 (0)