mirror of
https://github.com/edubart/otclient.git
synced 2025-10-20 22:43:27 +02:00
Tidy up the source code
* Replaced push_back calls with emplace_back where applicable. * Replaced size() == 0 and size() != 0 with empty() and !empty(). * Replaced C style loops for range for loops where applicable. * Fixed mismatching arg names between function declarations and definitions. * Replaced NULL and 0 (in the context of pointers) with nullptr. * Remove unnecessary calls to string::c_str() where applicable. * Replaced deprecated C headers with proper C++ headers. * Removed unnecessary null pointer checks when deleting pointers (deleting a null pointer has no effect). * Fixed a potential memory leak in apngloader.cpp file. * Replaced unsafe strcpy with strncpy in the demangle_name function.
This commit is contained in:
@@ -35,7 +35,7 @@ OggSoundFile::~OggSoundFile()
|
||||
bool OggSoundFile::prepareOgg()
|
||||
{
|
||||
ov_callbacks callbacks = { cb_read, cb_seek, cb_close, cb_tell };
|
||||
ov_open_callbacks(m_file.get(), &m_vorbisFile, 0, 0, callbacks);
|
||||
ov_open_callbacks(m_file.get(), &m_vorbisFile, nullptr, 0, callbacks);
|
||||
|
||||
vorbis_info* vi = ov_info(&m_vorbisFile, -1);
|
||||
if(!vi) {
|
||||
|
@@ -37,13 +37,13 @@ SoundManager g_sounds;
|
||||
|
||||
void SoundManager::init()
|
||||
{
|
||||
m_device = alcOpenDevice(NULL);
|
||||
m_device = alcOpenDevice(nullptr);
|
||||
if(!m_device) {
|
||||
g_logger.error("unable to open audio device");
|
||||
return;
|
||||
}
|
||||
|
||||
m_context = alcCreateContext(m_device, NULL);
|
||||
m_context = alcCreateContext(m_device, nullptr);
|
||||
if(!m_context) {
|
||||
g_logger.error(stdext::format("unable to create audio context: %s", alcGetString(m_device, alcGetError(m_device))));
|
||||
return;
|
||||
@@ -59,8 +59,8 @@ void SoundManager::terminate()
|
||||
{
|
||||
ensureContext();
|
||||
|
||||
for(auto it = m_streamFiles.begin(); it != m_streamFiles.end();++it) {
|
||||
auto& future = it->second;
|
||||
for(auto &streamFile: m_streamFiles) {
|
||||
auto& future = streamFile.second;
|
||||
future.wait();
|
||||
}
|
||||
m_streamFiles.clear();
|
||||
|
Reference in New Issue
Block a user