TINYGL: Fix some memory leaks
This commit is contained in:
parent
a2b44ab930
commit
bd14146a78
4 changed files with 20 additions and 1 deletions
|
@ -17,6 +17,7 @@ void endSharedState(GLContext *c) {
|
|||
GLSharedState *s = &c->shared_state;
|
||||
int i;
|
||||
|
||||
free_texture(c, 0);
|
||||
for (i = 0; i< MAX_DISPLAY_LISTS; i++) {
|
||||
// TODO
|
||||
}
|
||||
|
@ -183,7 +184,13 @@ void glInit(void *zbuffer1) {
|
|||
|
||||
void glClose() {
|
||||
GLContext *c = gl_get_context();
|
||||
|
||||
specbuf_cleanup(c);
|
||||
for (int i = 0; i < 3; i++)
|
||||
gl_free(c->matrix_stack[i]);
|
||||
endSharedState(c);
|
||||
gl_free(c->vertex);
|
||||
|
||||
gl_free(c);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,4 +47,14 @@ GLSpecBuf *specbuf_get_buffer(GLContext *c, const int shininess_i, const float s
|
|||
return oldest;
|
||||
}
|
||||
|
||||
void specbuf_cleanup(GLContext *c) {
|
||||
GLSpecBuf *buf, *next;
|
||||
buf = c->specbuf_first;
|
||||
for (int i = 0; i < c->specbuf_num_buffers; ++i) {
|
||||
next = buf->next;
|
||||
gl_free(buf);
|
||||
buf = next;
|
||||
}
|
||||
}
|
||||
|
||||
} // end of namespace TinyGL
|
||||
|
|
|
@ -17,7 +17,7 @@ static GLTexture *find_texture(GLContext *c, int h) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void free_texture(GLContext *c, int h) {
|
||||
void free_texture(GLContext *c, int h) {
|
||||
GLTexture *t, **ht;
|
||||
GLImage *im;
|
||||
int i;
|
||||
|
|
|
@ -300,6 +300,7 @@ void gl_shade_vertex(GLContext *c, GLVertex *v);
|
|||
void glInitTextures(GLContext *c);
|
||||
void glEndTextures(GLContext *c);
|
||||
GLTexture *alloc_texture(GLContext *c, int h);
|
||||
void free_texture(GLContext *c, int h);
|
||||
|
||||
// image_util.c
|
||||
void gl_resizeImage(unsigned char *dest, int xsize_dest, int ysize_dest,
|
||||
|
@ -311,6 +312,7 @@ GLContext *gl_get_context();
|
|||
|
||||
// specular buffer "api"
|
||||
GLSpecBuf *specbuf_get_buffer(GLContext *c, const int shininess_i, const float shininess);
|
||||
void specbuf_cleanup(GLContext *c); // free all memory used
|
||||
|
||||
void glInit(void *zbuffer);
|
||||
void glClose();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue