[Fix] More memory related fixes.
This commit is contained in:
parent
1f3947bc49
commit
1d734e7898
20
src/opengl.c
20
src/opengl.c
@ -346,6 +346,7 @@ glTexture* gl_loadImage(SDL_Surface* surface) {
|
|||||||
texture->sh = texture->h;
|
texture->sh = texture->h;
|
||||||
|
|
||||||
texture->trans = NULL;
|
texture->trans = NULL;
|
||||||
|
texture->name = NULL;
|
||||||
|
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
@ -365,19 +366,20 @@ glTexture* gl_newImage(const char* path) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate memory. */
|
|
||||||
if(texture_list == NULL) { /* Special condition - creating new list. */
|
|
||||||
texture_list = cur = malloc(sizeof(glTexList));
|
|
||||||
} else {
|
|
||||||
cur = malloc(sizeof(glTexList));
|
|
||||||
last->next = cur;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set node properties */
|
/* Create the new node. */
|
||||||
|
cur = malloc(sizeof(glTexList));
|
||||||
cur->next = NULL;
|
cur->next = NULL;
|
||||||
cur->tex = gl_loadNewImage(path);
|
|
||||||
cur->used = 1;
|
cur->used = 1;
|
||||||
|
|
||||||
|
/* Load the image. */
|
||||||
|
cur->tex = gl_loadNewImage(path);
|
||||||
|
|
||||||
|
if(texture_list == NULL) /* Special condition - creating new list. */
|
||||||
|
texture_list = cur;
|
||||||
|
else
|
||||||
|
last->next = cur;
|
||||||
|
|
||||||
return cur->tex;
|
return cur->tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,9 +276,12 @@ void spfx_render(const int layer) {
|
|||||||
spfx_nstack = spfx_nstack_back;
|
spfx_nstack = spfx_nstack_back;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Now render the layer. */
|
||||||
for(i = 0; i < spfx_nstack; i++) {
|
for(i = 0; i < spfx_nstack; i++) {
|
||||||
effect = &spfx_effects[spfx_stack[i].effect];
|
effect = &spfx_effects[spfx_stack[i].effect];
|
||||||
|
|
||||||
|
/* Simplifies. */
|
||||||
sx = (int)effect->gfx->sx;
|
sx = (int)effect->gfx->sx;
|
||||||
sy = (int)effect->gfx->sy;
|
sy = (int)effect->gfx->sy;
|
||||||
|
|
||||||
@ -286,6 +289,7 @@ void spfx_render(const int layer) {
|
|||||||
spfx_stack[i].lastframe = sx * sy
|
spfx_stack[i].lastframe = sx * sy
|
||||||
* MIN(((double)(spfx_stack[i].timer)/(double)effect->anim), 1.);
|
* MIN(((double)(spfx_stack[i].timer)/(double)effect->anim), 1.);
|
||||||
|
|
||||||
|
/* Render. */
|
||||||
gl_blitSprite(effect->gfx,
|
gl_blitSprite(effect->gfx,
|
||||||
VX(spfx_stack[i].pos), VY(spfx_stack[i].pos),
|
VX(spfx_stack[i].pos), VY(spfx_stack[i].pos),
|
||||||
spfx_stack[i].lastframe % sx,
|
spfx_stack[i].lastframe % sx,
|
||||||
|
@ -1670,11 +1670,9 @@ int toolkit_init(void) {
|
|||||||
|
|
||||||
/* Exit the toolkit. */
|
/* Exit the toolkit. */
|
||||||
void toolkit_exit(void) {
|
void toolkit_exit(void) {
|
||||||
int i;
|
while(nwindows > 0)
|
||||||
for(i = 0; i < nwindows; i++) {
|
window_destroy(windows[0].id);
|
||||||
window_destroy(windows[i].id);
|
|
||||||
free(windows);
|
free(windows);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Spawns a secondary loop that only works until the toolkit dies. */
|
/* Spawns a secondary loop that only works until the toolkit dies. */
|
||||||
|
Loading…
Reference in New Issue
Block a user