Merge pull request #431 from Kratos714/master
Fixed some minor memory issues
This commit is contained in:
commit
7cd545bd96
@ -97,6 +97,7 @@ bool SoundFile::openRead(const std::string& filename)
|
||||
|
||||
// Open the sound file
|
||||
SF_INFO fileInfo;
|
||||
fileInfo.format = 0;
|
||||
m_file = sf_open(filename.c_str(), SFM_READ, &fileInfo);
|
||||
if (!m_file)
|
||||
{
|
||||
@ -132,6 +133,7 @@ bool SoundFile::openRead(const void* data, std::size_t sizeInBytes)
|
||||
|
||||
// Open the sound file
|
||||
SF_INFO fileInfo;
|
||||
fileInfo.format = 0;
|
||||
m_file = sf_open_virtual(&io, SFM_READ, &fileInfo, &m_memory);
|
||||
if (!m_file)
|
||||
{
|
||||
@ -169,6 +171,7 @@ bool SoundFile::openRead(InputStream& stream)
|
||||
|
||||
// Open the sound file
|
||||
SF_INFO fileInfo;
|
||||
fileInfo.format = 0;
|
||||
m_file = sf_open_virtual(&io, SFM_READ, &fileInfo, &m_stream);
|
||||
if (!m_file)
|
||||
{
|
||||
|
@ -60,21 +60,18 @@ namespace
|
||||
}
|
||||
|
||||
// Find the name of the current executable
|
||||
const char* findExecutableName()
|
||||
void findExecutableName(char* buffer, std::size_t bufferSize)
|
||||
{
|
||||
char buffer[512];
|
||||
std::size_t length = readlink("/proc/self/exe", buffer, sizeof(buffer));
|
||||
if ((length > 0) && (length < sizeof(buffer)))
|
||||
//Default fallback name
|
||||
const char* executableName = "sfml";
|
||||
std::size_t length = readlink("/proc/self/exe", buffer, bufferSize);
|
||||
if ((length > 0) && (length < bufferSize))
|
||||
{
|
||||
// Remove the path to keep the executable name only
|
||||
buffer[length] = '\0';
|
||||
return basename(buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fallback name
|
||||
return "sfml";
|
||||
executableName = basename(buffer);
|
||||
}
|
||||
std::memmove(buffer, executableName, std::strlen(executableName) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -249,10 +246,11 @@ m_previousSize(-1, -1)
|
||||
}
|
||||
|
||||
// Set the window's WM class (this can be used by window managers)
|
||||
const char* windowClass = findExecutableName();
|
||||
char windowClass[512];
|
||||
findExecutableName(windowClass, sizeof(windowClass));
|
||||
XClassHint* classHint = XAllocClassHint();
|
||||
classHint->res_name = const_cast<char*>(windowClass);
|
||||
classHint->res_class = const_cast<char*>(windowClass);
|
||||
classHint->res_name = windowClass;
|
||||
classHint->res_class = windowClass;
|
||||
XSetClassHint(m_display, m_window, classHint);
|
||||
XFree(classHint);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user