File tree Expand file tree Collapse file tree 4 files changed +16
-18
lines changed Expand file tree Collapse file tree 4 files changed +16
-18
lines changed Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ CSFML_AUDIO_API bool sfSoundRecorder_isAvailable(void);
129129/// \return An array of strings containing the names
130130///
131131////////////////////////////////////////////////////////////
132- CSFML_AUDIO_API const char * * sfSoundRecorder_getAvailableDevices (size_t * count );
132+ CSFML_AUDIO_API const char * const * sfSoundRecorder_getAvailableDevices (size_t * count );
133133
134134////////////////////////////////////////////////////////////
135135/// \brief Get the name of the default audio capture device
Original file line number Diff line number Diff line change @@ -81,18 +81,17 @@ bool sfSoundRecorder_isAvailable()
8181
8282
8383// //////////////////////////////////////////////////////////
84- const char ** sfSoundRecorder_getAvailableDevices (size_t * count)
84+ const char * const * sfSoundRecorder_getAvailableDevices (size_t * count)
8585{
86- static std::vector<std::string> stringDevices = sf::SoundRecorder::getAvailableDevices ();
87- static std::vector<const char *> cstringDevices;
88-
89- if (cstringDevices.empty () && !stringDevices.empty ())
86+ static const auto cstringDevices = []
9087 {
88+ static const std::vector<std::string> stringDevices = sf::SoundRecorder::getAvailableDevices ();
89+ std::vector<const char *> devices;
90+ devices.reserve (stringDevices.size ());
9191 for (const auto & stringDevice : stringDevices)
92- {
93- cstringDevices.push_back (stringDevice.c_str ());
94- }
95- }
92+ devices.push_back (stringDevice.c_str ());
93+ return devices;
94+ }();
9695
9796 if (count)
9897 *count = cstringDevices.size ();
@@ -104,7 +103,7 @@ const char** sfSoundRecorder_getAvailableDevices(size_t* count)
104103// //////////////////////////////////////////////////////////
105104const char * sfSoundRecorder_getDefaultDevice ()
106105{
107- static std::string defaultDevice = sf::SoundRecorder::getDefaultDevice ();
106+ static const std::string defaultDevice = sf::SoundRecorder::getDefaultDevice ();
108107
109108 return !defaultDevice.empty () ? defaultDevice.c_str () : nullptr ;
110109}
Original file line number Diff line number Diff line change @@ -41,14 +41,13 @@ sfVideoMode sfVideoMode_getDesktopMode()
4141// //////////////////////////////////////////////////////////
4242const sfVideoMode* sfVideoMode_getFullscreenModes (size_t * count)
4343{
44- static std::vector<sfVideoMode> modes;
45-
46- // Populate the array on first call
47- if (modes.empty ())
44+ static const auto modes = []
4845 {
46+ std::vector<sfVideoMode> videomodes;
4947 for (const auto & mode : sf::VideoMode::getFullscreenModes ())
50- modes.push_back (convertVideoMode (mode));
51- }
48+ videomodes.push_back (convertVideoMode (mode));
49+ return videomodes;
50+ }();
5251
5352 if (count)
5453 *count = modes.size ();
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ sfVulkanFunctionPointer sfVulkan_getFunction(const char* name)
5252// //////////////////////////////////////////////////////////
5353const char * const * sfVulkan_getGraphicsRequiredInstanceExtensions (size_t * count)
5454{
55- static std::vector<const char *> extensions = sf::Vulkan::getGraphicsRequiredInstanceExtensions ();
55+ static const std::vector<const char *> extensions = sf::Vulkan::getGraphicsRequiredInstanceExtensions ();
5656
5757 if (count)
5858 *count = extensions.size ();
You can’t perform that action at this time.
0 commit comments