Fix memory leaks in samples
Add free to end of LoadGLTextures() to release image1 after use.
This commit is contained in:
parent
06529d4fe7
commit
3d6c756ab7
|
@ -134,6 +134,8 @@ void LoadGLTextures() {
|
||||||
// 2d texture, level of detail 0 (normal), 3 components (red, green, blue), x size from image, y size from image,
|
// 2d texture, level of detail 0 (normal), 3 components (red, green, blue), x size from image, y size from image,
|
||||||
// border 0 (normal), rgb color data, unsigned byte data, and finally the data itself.
|
// border 0 (normal), rgb color data, unsigned byte data, and finally the data itself.
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, 3, image1->sizeX, image1->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, image1->data);
|
glTexImage2D(GL_TEXTURE_2D, 0, 3, image1->sizeX, image1->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, image1->data);
|
||||||
|
|
||||||
|
free(image1);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* A general OpenGL initialization function. Sets all of the initial parameters. */
|
/* A general OpenGL initialization function. Sets all of the initial parameters. */
|
||||||
|
|
|
@ -141,6 +141,8 @@ void LoadGLTextures() {
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, 3, image1->sizeX, image1->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, image1->data);
|
glTexImage2D(GL_TEXTURE_2D, 0, 3, image1->sizeX, image1->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, image1->data);
|
||||||
|
|
||||||
glGenerateMipmapEXT(GL_TEXTURE_2D);
|
glGenerateMipmapEXT(GL_TEXTURE_2D);
|
||||||
|
|
||||||
|
free(image1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -137,6 +137,8 @@ void LoadGLTextures() {
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, 3, image1->sizeX, image1->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, image1->data);
|
glTexImage2D(GL_TEXTURE_2D, 0, 3, image1->sizeX, image1->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, image1->data);
|
||||||
|
|
||||||
glGenerateMipmapEXT(GL_TEXTURE_2D);
|
glGenerateMipmapEXT(GL_TEXTURE_2D);
|
||||||
|
|
||||||
|
free(image1);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* A general OpenGL initialization function. Sets all of the initial parameters. */
|
/* A general OpenGL initialization function. Sets all of the initial parameters. */
|
||||||
|
|
|
@ -140,6 +140,8 @@ void LoadGLTextures() {
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, 3, image1->sizeX, image1->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, image1->data);
|
glTexImage2D(GL_TEXTURE_2D, 0, 3, image1->sizeX, image1->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, image1->data);
|
||||||
|
|
||||||
glGenerateMipmapEXT(GL_TEXTURE_2D);
|
glGenerateMipmapEXT(GL_TEXTURE_2D);
|
||||||
|
|
||||||
|
free(image1);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* A general OpenGL initialization function. Sets all of the initial parameters. */
|
/* A general OpenGL initialization function. Sets all of the initial parameters. */
|
||||||
|
|
|
@ -156,6 +156,8 @@ void LoadGLTextures() {
|
||||||
GL_TEXTURE_2D, 0, image1->internal_format, image1->sizeX, image1->sizeY, 0,
|
GL_TEXTURE_2D, 0, image1->internal_format, image1->sizeX, image1->sizeY, 0,
|
||||||
image1->format, image1->type, image1->data
|
image1->format, image1->type, image1->data
|
||||||
);
|
);
|
||||||
|
|
||||||
|
free(image1);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* A general OpenGL initialization function. Sets all of the initial parameters. */
|
/* A general OpenGL initialization function. Sets all of the initial parameters. */
|
||||||
|
|
|
@ -162,6 +162,8 @@ void LoadGLTextures() {
|
||||||
GL_TEXTURE_2D, 0, image1->internalFormat, image1->sizeX, image1->sizeY, 0,
|
GL_TEXTURE_2D, 0, image1->internalFormat, image1->sizeX, image1->sizeY, 0,
|
||||||
image1->dataSize, image1->data
|
image1->dataSize, image1->data
|
||||||
);
|
);
|
||||||
|
|
||||||
|
free(image1);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* A general OpenGL initialization function. Sets all of the initial parameters. */
|
/* A general OpenGL initialization function. Sets all of the initial parameters. */
|
||||||
|
|
|
@ -125,6 +125,8 @@ void LoadGLTextures() {
|
||||||
// border 0 (normal), rgb color data, unsigned byte data, and finally the data itself.
|
// border 0 (normal), rgb color data, unsigned byte data, and finally the data itself.
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, image1->width, image1->height, 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE_TWID_KOS, image1->data);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, image1->width, image1->height, 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE_TWID_KOS, image1->data);
|
||||||
glGenerateMipmapEXT(GL_TEXTURE_2D);
|
glGenerateMipmapEXT(GL_TEXTURE_2D);
|
||||||
|
|
||||||
|
free(image1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A general OpenGL initialization function. Sets all of the initial parameters. */
|
/* A general OpenGL initialization function. Sets all of the initial parameters. */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user