mirror of
https://github.com/love2d/love.git
synced 2026-08-12 16:40:57 +02:00
Fix 3/4 of issue #327: memory allocation issues.
This commit is contained in:
+6
-6
@@ -36,12 +36,12 @@ namespace love
|
||||
// Convert to UTF-8.
|
||||
int ok = WideCharToMultiByte(CP_UTF8, 0, wstr, wide_len, utf8_str, utf8_size, 0, 0);
|
||||
|
||||
if(!ok)
|
||||
{
|
||||
delete [] utf8_str;
|
||||
}
|
||||
std::string ret;
|
||||
if (ok)
|
||||
ret = utf8_str;
|
||||
|
||||
return ok ? std::string(utf8_str) : std::string();
|
||||
delete utf8_str;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void replace_char(std::string & str, char find, char replace)
|
||||
@@ -57,4 +57,4 @@ namespace love
|
||||
|
||||
} // love
|
||||
|
||||
#endif // LOVE_WINDOWS
|
||||
#endif // LOVE_WINDOWS
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace graphics
|
||||
namespace opengl
|
||||
{
|
||||
// A fragment shader
|
||||
class PixelEffect : public Volatile // Volatile?
|
||||
class PixelEffect : public Volatile, public Object
|
||||
{
|
||||
public:
|
||||
PixelEffect(const std::string& code);
|
||||
|
||||
@@ -245,6 +245,7 @@ namespace opengl
|
||||
|
||||
int w_newFont1(lua_State * L)
|
||||
{
|
||||
Data * font_data = NULL;
|
||||
// Convert to File, if necessary.
|
||||
if(lua_isstring(L, 1))
|
||||
luax_convobj(L, 1, "filesystem", "newFile");
|
||||
@@ -252,15 +253,14 @@ namespace opengl
|
||||
// Convert to Data, if necessary.
|
||||
if(luax_istype(L, 1, FILESYSTEM_FILE_T)) {
|
||||
love::filesystem::File * f = luax_checktype<love::filesystem::File>(L, 1, "File", FILESYSTEM_FILE_T);
|
||||
Data * d;
|
||||
try {
|
||||
d = f->read();
|
||||
font_data = f->read();
|
||||
}
|
||||
catch (love::Exception & e) {
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
lua_remove(L, 1); // get rid of the file
|
||||
luax_newtype(L, "Data", DATA_T, (void*)d);
|
||||
luax_newtype(L, "Data", DATA_T, (void*)font_data);
|
||||
lua_insert(L, 1); // put it at the bottom of the stack
|
||||
}
|
||||
|
||||
@@ -270,6 +270,9 @@ namespace opengl
|
||||
luax_convobj(L, idxs, 2, "font", "newRasterizer");
|
||||
}
|
||||
|
||||
if (font_data)
|
||||
font_data->release();
|
||||
|
||||
love::font::Rasterizer * rasterizer = luax_checktype<love::font::Rasterizer>(L, 1, "Rasterizer", FONT_RASTERIZER_T);
|
||||
|
||||
// Create the font.
|
||||
|
||||
Reference in New Issue
Block a user