Skip to content

Commit 3361c2d

Browse files
committed
fix: Remove static.
1 parent fa0f84a commit 3361c2d

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/include/Config/PlatformConfig.hpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,6 @@ namespace pew::eos::config
4444
*/
4545
struct PlatformConfig : Config
4646
{
47-
public:
48-
49-
/**
50-
* \brief Used to statically store the platform specific rtc options once it they been determined.
51-
*/
52-
static inline void* s_platform_specific_rtc_options;
53-
5447
/**
5548
* \brief The deployment for the platform.
5649
*/
@@ -159,9 +152,14 @@ namespace pew::eos::config
159152
*/
160153
std::string cache_directory;
161154

155+
/**
156+
* \brief Used to statically store the platform specific rtc options once they have been determined.
157+
*/
158+
void* platform_specific_rtc_options;
159+
162160
virtual void set_cache_directory() = 0;
163161

164-
virtual void set_platform_specific_rtc_options() const = 0;
162+
virtual void set_platform_specific_rtc_options() = 0;
165163

166164
/**
167165
* \brief Used to store the rtc options once it has been determined.
@@ -289,13 +287,8 @@ namespace pew::eos::config
289287

290288
virtual ~PlatformConfig()
291289
{
292-
// Free the dynamically allocated memory for the platform specific RTC options.
293-
if (s_platform_specific_rtc_options)
294-
delete s_platform_specific_rtc_options;
295-
296290
// Free the dynamically allocated memory for the rtc options
297-
if (rtc_options != nullptr)
298-
delete rtc_options;
291+
delete rtc_options;
299292
};
300293

301294
private:
@@ -312,6 +305,7 @@ namespace pew::eos::config
312305

313306
void initialize()
314307
{
308+
set_platform_rtc_options();
315309
set_cache_directory();
316310
}
317311
};

lib/NativeCode/DynamicLibraryLoaderHelper/NativeRender/include/Config/WindowsConfig.hpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ namespace pew::eos::config
3131
{
3232
struct WindowsConfig final : PlatformConfig
3333
{
34-
~WindowsConfig() = default;
34+
~WindowsConfig() override
35+
{
36+
delete static_cast<EOS_Windows_RTCOptions*>(platform_specific_rtc_options);
37+
}
3538

3639
void set_cache_directory() override
3740
{
@@ -47,7 +50,7 @@ namespace pew::eos::config
4750
}
4851
}
4952

50-
void set_platform_specific_rtc_options() const override
53+
void set_platform_specific_rtc_options() override
5154
{
5255
if (rtc_options == nullptr)
5356
{
@@ -57,9 +60,9 @@ namespace pew::eos::config
5760

5861
if (rtc_options->PlatformSpecificOptions == nullptr)
5962
{
60-
s_platform_specific_rtc_options = new EOS_Windows_RTCOptions();
63+
platform_specific_rtc_options = new EOS_Windows_RTCOptions();
6164

62-
const auto windows_rtc_options = reinterpret_cast<EOS_Windows_RTCOptions*>(s_platform_specific_rtc_options);
65+
const auto windows_rtc_options = static_cast<EOS_Windows_RTCOptions*>(platform_specific_rtc_options);
6366

6467
windows_rtc_options->ApiVersion = EOS_WINDOWS_RTCOPTIONS_API_LATEST;
6568

@@ -71,23 +74,22 @@ namespace pew::eos::config
7174
}
7275

7376
size_t len = xaudio2_dll_path.string().size() + 1;
74-
s_xaudio2_dll_path = std::unique_ptr<char[]>(new char[len]);
77+
_xaudio2_dll_path = std::shared_ptr<char[]>(new char[len]);
7578

76-
strcpy_s(s_xaudio2_dll_path.get(), len, xaudio2_dll_path.string().c_str());
79+
strcpy_s(_xaudio2_dll_path.get(), len, xaudio2_dll_path.string().c_str());
7780

78-
windows_rtc_options->XAudio29DllPath = s_xaudio2_dll_path.get();
81+
windows_rtc_options->XAudio29DllPath = _xaudio2_dll_path.get();
7982

80-
rtc_options->PlatformSpecificOptions = s_platform_specific_rtc_options;
83+
rtc_options->PlatformSpecificOptions = platform_specific_rtc_options;
8184
}
8285
}
8386

8487
private:
8588

86-
static inline std::unique_ptr<char[]> s_xaudio2_dll_path;
89+
std::shared_ptr<char[]> _xaudio2_dll_path;
8790

8891
explicit WindowsConfig() : PlatformConfig("eos_windows_config.json")
8992
{
90-
get_cache_directory();
9193
}
9294
// Makes the WindowsConfig constructor accessible to the Config class.
9395
friend struct Config;

0 commit comments

Comments
 (0)