Unverified Commit 1337a4f4 authored by Libretro-Admin's avatar Libretro-Admin Committed by GitHub
Browse files

Merge pull request #24 from BringerethOfLight/master

fixes some of the remaining memory access issues
parents 359b5137 44fc059d
DEBUG=0 DEBUG ?= 0
PERF_TEST=0 PERF_TEST ?= 0
HAVE_SHARED_CONTEXT=0 HAVE_SHARED_CONTEXT ?= 0
HAVE_OPENGL=1 HAVE_OPENGL ?= 1
FORCE_GLES=0 FORCE_GLES ?= 0
HAVE_LIBCURL=0 HAVE_LIBCURL ?= 0
INCFLAGS := INCFLAGS :=
......
...@@ -1224,6 +1224,15 @@ static void compute_chunk(WorkerItem *item) ...@@ -1224,6 +1224,15 @@ static void compute_chunk(WorkerItem *item)
int oz = item->q * CHUNK_SIZE - CHUNK_SIZE - 1; int oz = item->q * CHUNK_SIZE - CHUNK_SIZE - 1;
/* check for lights */ /* check for lights */
int has_light = 0; int has_light = 0;
if (!opaque || !light || !highest)
{
free(opaque);
free(light);
free(highest);
return;
}
if (SHOW_LIGHTS) if (SHOW_LIGHTS)
{ {
for (a = 0; a < 3; a++) for (a = 0; a < 3; a++)
...@@ -1402,6 +1411,7 @@ static void compute_chunk(WorkerItem *item) ...@@ -1402,6 +1411,7 @@ static void compute_chunk(WorkerItem *item)
item->miny = miny; item->miny = miny;
item->maxy = maxy; item->maxy = maxy;
item->faces = faces; item->faces = faces;
free(item->data);
item->data = data; item->data = data;
} }
} }
...@@ -1412,6 +1422,7 @@ static void generate_chunk(Chunk *chunk, WorkerItem *item) { ...@@ -1412,6 +1422,7 @@ static void generate_chunk(Chunk *chunk, WorkerItem *item) {
chunk->faces = item->faces; chunk->faces = item->faces;
renderer_del_buffer(chunk->buffer); renderer_del_buffer(chunk->buffer);
chunk->buffer = renderer_gen_faces(10, item->faces, item->data); chunk->buffer = renderer_gen_faces(10, item->faces, item->data);
item->data = 0;
gen_sign_buffer(chunk); gen_sign_buffer(chunk);
} }
...@@ -1421,6 +1432,8 @@ static void gen_chunk_buffer(Chunk *chunk) ...@@ -1421,6 +1432,8 @@ static void gen_chunk_buffer(Chunk *chunk)
WorkerItem _item; WorkerItem _item;
WorkerItem *item = &_item; WorkerItem *item = &_item;
memset(item, 0, sizeof(*item));
item->p = chunk->p; item->p = chunk->p;
item->q = chunk->q; item->q = chunk->q;
...@@ -1502,11 +1515,11 @@ static void init_chunk(Chunk *chunk, int p, int q) ...@@ -1502,11 +1515,11 @@ static void init_chunk(Chunk *chunk, int p, int q)
static void create_chunk(Chunk *chunk, int p, int q) static void create_chunk(Chunk *chunk, int p, int q)
{ {
WorkerItem _item; WorkerItem _item;
WorkerItem *item; WorkerItem *item = &_item;
memset(item, 0, sizeof(*item));
init_chunk(chunk, p, q); init_chunk(chunk, p, q);
item = &_item;
item->p = chunk->p; item->p = chunk->p;
item->q = chunk->q; item->q = chunk->q;
item->block_maps[1][1] = &chunk->map; item->block_maps[1][1] = &chunk->map;
...@@ -3350,6 +3363,7 @@ int main_load_game(int argc, char **argv) ...@@ -3350,6 +3363,7 @@ int main_load_game(int argc, char **argv)
// INITIALIZE WORKER THREADS // INITIALIZE WORKER THREADS
for (i = 0; i < WORKERS; i++) { for (i = 0; i < WORKERS; i++) {
Worker *worker = g->workers + i; Worker *worker = g->workers + i;
memset(worker, 0, sizeof(*worker));
worker->index = i; worker->index = i;
worker->state = WORKER_IDLE; worker->state = WORKER_IDLE;
mtx_init(&worker->mtx, mtx_plain); mtx_init(&worker->mtx, mtx_plain);
......
...@@ -398,6 +398,8 @@ uintptr_t renderer_gen_buffer(size_t size, float *data) ...@@ -398,6 +398,8 @@ uintptr_t renderer_gen_buffer(size_t size, float *data)
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
GLuint buffer; GLuint buffer;
glGenBuffers(1, &buffer); glGenBuffers(1, &buffer);
if (!size || !data)
return buffer;
glBindBuffer(GL_ARRAY_BUFFER, buffer); glBindBuffer(GL_ARRAY_BUFFER, buffer);
glBufferData(GL_ARRAY_BUFFER, (GLsizei)size, data, GL_STATIC_DRAW); glBufferData(GL_ARRAY_BUFFER, (GLsizei)size, data, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment