From 0bcd8d46eee75eb8ea5f310e8d2270dd67ca9253 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Fri, 3 Jun 2016 06:31:15 -0700 Subject: [PATCH] Memory workaround --- project/src/ExternalInterface.cpp | 16 ++++++---- project/src/audio/openal/OpenALBindings.cpp | 3 +- .../src/graphics/opengl/OpenGLBindings.cpp | 31 ++++++++++++------- project/src/math/ColorMatrix.cpp | 3 +- project/src/net/curl/CURLBindings.cpp | 3 +- 5 files changed, 36 insertions(+), 20 deletions(-) diff --git a/project/src/ExternalInterface.cpp b/project/src/ExternalInterface.cpp index c123f5993..aaeabaa24 100644 --- a/project/src/ExternalInterface.cpp +++ b/project/src/ExternalInterface.cpp @@ -164,8 +164,8 @@ namespace lime { } else { - bytes = Bytes(); - bytes.Set(data); + bytes = Bytes (); + bytes.Set (data); resource = Resource (&bytes); } @@ -918,7 +918,8 @@ namespace lime { ImageBuffer imageBuffer; - Bytes bytes (data); + Bytes bytes; + bytes.Set (data); Resource resource = Resource (&bytes); #ifdef LIME_JPEG @@ -963,7 +964,8 @@ namespace lime { value lime_lzma_decode (value buffer) { #ifdef LIME_LZMA - Bytes data = Bytes (buffer); + Bytes data; + data.Set (buffer); Bytes result; LZMA::Decode (&data, &result); @@ -979,7 +981,8 @@ namespace lime { value lime_lzma_encode (value buffer) { #ifdef LIME_LZMA - Bytes data = Bytes (buffer); + Bytes data; + data.Set (buffer); Bytes result; LZMA::Encode (&data, &result); @@ -1284,7 +1287,8 @@ namespace lime { TextLayout *text = (TextLayout*)val_data (textHandle); Font *font = (Font*)val_data (fontHandle); - Bytes bytes = Bytes (data); + Bytes bytes; + bytes.Set (data); text->Position (font, size, textString.__s, &bytes); return bytes.Value (); diff --git a/project/src/audio/openal/OpenALBindings.cpp b/project/src/audio/openal/OpenALBindings.cpp index 90a0a37bf..2fa5afdbe 100644 --- a/project/src/audio/openal/OpenALBindings.cpp +++ b/project/src/audio/openal/OpenALBindings.cpp @@ -17,7 +17,8 @@ namespace lime { void lime_al_buffer_data (int buffer, int format, value data, int size, int freq) { - Bytes bytes (data); + Bytes bytes; + bytes.Set (data); alBufferData (buffer, format, bytes.Data (), size, freq); } diff --git a/project/src/graphics/opengl/OpenGLBindings.cpp b/project/src/graphics/opengl/OpenGLBindings.cpp index 73161e142..37af3d6ed 100644 --- a/project/src/graphics/opengl/OpenGLBindings.cpp +++ b/project/src/graphics/opengl/OpenGLBindings.cpp @@ -165,7 +165,8 @@ namespace lime { if (len == 0) return; - Bytes bytes (inByteBuffer); + Bytes bytes; + bytes.Set (inByteBuffer); const unsigned char *data = bytes.Data (); int size = bytes.Length (); @@ -184,8 +185,8 @@ namespace lime { if (len == 0) return; - Bytes bytes (inByteBuffer); - + Bytes bytes; + bytes.Set (inByteBuffer); const unsigned char *data = bytes.Data (); int size = bytes.Length (); @@ -258,7 +259,8 @@ namespace lime { unsigned char *data = 0; int size = 0; - Bytes bytes (buffer); + Bytes bytes; + bytes.Set (buffer); if (bytes.Length ()) { @@ -277,7 +279,8 @@ namespace lime { unsigned char *data = 0; int size = 0; - Bytes bytes (buffer); + Bytes bytes; + bytes.Set (buffer); if (bytes.Length ()) { @@ -1203,7 +1206,8 @@ namespace lime { void lime_gl_read_pixels (int x, int y, int width, int height, int format, int type, value buffer, int offset) { unsigned char *data = 0; - Bytes bytes (buffer); + Bytes bytes; + bytes.Set (buffer); if (bytes.Length ()) { @@ -1290,7 +1294,8 @@ namespace lime { unsigned char *data = 0; - Bytes bytes (buffer); + Bytes bytes; + bytes.Set (buffer); if (bytes.Length ()) { @@ -1320,7 +1325,8 @@ namespace lime { void lime_gl_tex_sub_image_2d (int target, int level, int xOffset, int yOffset, int width, int height, int format, int type, value buffer, int offset) { unsigned char *data = 0; - Bytes bytes (buffer); + Bytes bytes; + bytes.Set (buffer); if (bytes.Length ()) { @@ -1335,7 +1341,8 @@ namespace lime { void lime_gl_uniform_matrix (int loc, bool trans, value inBytes, int count) { - Bytes bytes (inBytes); + Bytes bytes; + bytes.Set (inBytes); int size = bytes.Length (); const float *data = (float *)bytes.Data (); int nbElems = size / sizeof (float); @@ -1360,7 +1367,8 @@ namespace lime { void lime_gl_uniform1fv (int loc, value inByteBuffer) { - Bytes bytes (inByteBuffer); + Bytes bytes; + bytes.Set (inByteBuffer); int size = bytes.Length (); const float *data = (float *)bytes.Data (); int nbElems = size / sizeof (float); @@ -1379,7 +1387,8 @@ namespace lime { void lime_gl_uniform1iv (int loc, value inByteBuffer) { - Bytes bytes (inByteBuffer); + Bytes bytes; + bytes.Set (inByteBuffer); int size = bytes.Length (); const int *data = (int *)bytes.Data (); int nbElems = size / sizeof (int); diff --git a/project/src/math/ColorMatrix.cpp b/project/src/math/ColorMatrix.cpp index 57f5a1531..887dbe057 100644 --- a/project/src/math/ColorMatrix.cpp +++ b/project/src/math/ColorMatrix.cpp @@ -38,7 +38,8 @@ namespace lime { } value buffer_value = val_field (colorMatrix, id_buffer); - Bytes bytes = Bytes (buffer_value); + Bytes bytes; + bytes.Set (buffer_value); float* src = (float*)bytes.Data (); for (int i = 0; i < 20; i++) { diff --git a/project/src/net/curl/CURLBindings.cpp b/project/src/net/curl/CURLBindings.cpp index 167c7d3dc..9a86b73a1 100644 --- a/project/src/net/curl/CURLBindings.cpp +++ b/project/src/net/curl/CURLBindings.cpp @@ -188,7 +188,8 @@ namespace lime { AutoGCRoot* callback = (AutoGCRoot*)userp; size_t length = size * nmemb; - Bytes bytes = Bytes (val_call1 (callback->get (), alloc_int (length))); + Bytes bytes; + bytes.Set (val_call1 (callback->get (), alloc_int (length))); if (bytes.Length () <= length) length = bytes.Length ();