[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->trans = NULL;
|
||||
texture->name = NULL;
|
||||
|
||||
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->tex = gl_loadNewImage(path);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -276,9 +276,12 @@ void spfx_render(const int layer) {
|
||||
spfx_nstack = spfx_nstack_back;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Now render the layer. */
|
||||
for(i = 0; i < spfx_nstack; i++) {
|
||||
effect = &spfx_effects[spfx_stack[i].effect];
|
||||
|
||||
/* Simplifies. */
|
||||
sx = (int)effect->gfx->sx;
|
||||
sy = (int)effect->gfx->sy;
|
||||
|
||||
@ -286,6 +289,7 @@ void spfx_render(const int layer) {
|
||||
spfx_stack[i].lastframe = sx * sy
|
||||
* MIN(((double)(spfx_stack[i].timer)/(double)effect->anim), 1.);
|
||||
|
||||
/* Render. */
|
||||
gl_blitSprite(effect->gfx,
|
||||
VX(spfx_stack[i].pos), VY(spfx_stack[i].pos),
|
||||
spfx_stack[i].lastframe % sx,
|
||||
|
@ -1670,12 +1670,10 @@ int toolkit_init(void) {
|
||||
|
||||
/* Exit the toolkit. */
|
||||
void toolkit_exit(void) {
|
||||
int i;
|
||||
for(i = 0; i < nwindows; i++) {
|
||||
window_destroy(windows[i].id);
|
||||
while(nwindows > 0)
|
||||
window_destroy(windows[0].id);
|
||||
free(windows);
|
||||
}
|
||||
}
|
||||
|
||||
/* Spawns a secondary loop that only works until the toolkit dies. */
|
||||
/* A lot like the main while loop in lephisto.c. */
|
||||
|
Loading…
Reference in New Issue
Block a user