Merge pull request #1708 from heuripedes/master

Memory handling fixes
This commit is contained in:
Twinaphex 2015-05-19 19:03:57 +02:00
commit 15d7740eb4
5 changed files with 20 additions and 13 deletions

View File

@ -30,14 +30,14 @@
#include "config.h"
#endif
static driver_t *g_driver;
static driver_t *g_driver = NULL;
void driver_free(void)
{
driver_t *driver = driver_get_ptr();
if (g_driver)
free(g_driver);
if (driver)
free(driver);
g_driver = NULL;
}
static driver_t *driver_new(void)

View File

@ -2926,6 +2926,12 @@ static void gl_overlay_vertex_geom(void *data,
if (!gl)
return;
if (image > gl->overlays)
{
RARCH_ERR("Invalid overlay id: %u\n", image);
return;
}
vertex = (GLfloat*)&gl->overlay_vertex_coord[image * 8];
/* Flipped, so we preserve top-down semantics. */

View File

@ -199,7 +199,7 @@ bool gl_coord_array_add(gl_coord_array_t *ca, const gl_coords_t *coords, unsigne
if (success)
{
size_t base_size = coords->vertices * sizeof(GLfloat);
size_t base_size = count * sizeof(GLfloat);
size_t offset = ca->coords.vertices;
/* XXX: i wish we used interlaced arrays so we could call memcpy only once */

View File

@ -29,6 +29,8 @@
font_color[ 4 * (6 * i + c) + 1] = color[1]; \
font_color[ 4 * (6 * i + c) + 2] = color[2]; \
font_color[ 4 * (6 * i + c) + 3] = color[3]; \
font_lut_tex_coord[ 4 * (6 * i + c) + 0] = gl->coords.lut_tex_coord[0]; \
font_lut_tex_coord[ 4 * (6 * i + c) + 1] = gl->coords.lut_tex_coord[1]; \
} while(0)
#define MAX_MSG_LEN_CHUNK 64
@ -181,6 +183,7 @@ static void gl_raster_font_render_message(
GLfloat font_tex_coords[2 * 6 * MAX_MSG_LEN_CHUNK];
GLfloat font_vertex[2 * 6 * MAX_MSG_LEN_CHUNK];
GLfloat font_color[4 * 6 * MAX_MSG_LEN_CHUNK];
GLfloat font_lut_tex_coord[2 * 6 * MAX_MSG_LEN_CHUNK];
struct gl_coords coords;
gl_t *gl = font ? font->gl : NULL;
@ -246,7 +249,7 @@ static void gl_raster_font_render_message(
coords.vertex = font_vertex;
coords.color = font_color;
coords.vertices = 6 * msg_len;
coords.lut_tex_coord = gl->coords.lut_tex_coord;
coords.lut_tex_coord = font_lut_tex_coord;
if (font->block)
gl_coord_array_add(&font->block->carr, &coords, coords.vertices);

View File

@ -35,9 +35,8 @@
#include "netplay.h"
#endif
static struct runloop *g_runloop;
static struct global *g_extern;
static struct runloop *g_runloop = NULL;
static struct global *g_extern = NULL;
/**
* check_pause:
@ -941,12 +940,11 @@ runloop_t *rarch_main_get_ptr(void)
void rarch_main_state_free(void)
{
runloop_t *runloop = rarch_main_get_ptr();
if (!runloop)
if (!g_runloop)
return;
free(runloop);
free(g_runloop);
g_runloop = NULL;
}
void rarch_main_global_free(void)