Fix memory leaks in samples

Add free to end of LoadGLTextures() to release image1 after use.
This commit is contained in:
Colton Pawielski 2021-05-14 08:57:10 -04:00
parent 06529d4fe7
commit 3d6c756ab7
7 changed files with 14 additions and 0 deletions

View File

@ -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,
// 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);
free(image1);
};
/* A general OpenGL initialization function. Sets all of the initial parameters. */

View File

@ -141,6 +141,8 @@ void LoadGLTextures() {
glTexImage2D(GL_TEXTURE_2D, 0, 3, image1->sizeX, image1->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, image1->data);
glGenerateMipmapEXT(GL_TEXTURE_2D);
free(image1);
};

View File

@ -137,6 +137,8 @@ void LoadGLTextures() {
glTexImage2D(GL_TEXTURE_2D, 0, 3, image1->sizeX, image1->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, image1->data);
glGenerateMipmapEXT(GL_TEXTURE_2D);
free(image1);
};
/* A general OpenGL initialization function. Sets all of the initial parameters. */

View File

@ -140,6 +140,8 @@ void LoadGLTextures() {
glTexImage2D(GL_TEXTURE_2D, 0, 3, image1->sizeX, image1->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, image1->data);
glGenerateMipmapEXT(GL_TEXTURE_2D);
free(image1);
};
/* A general OpenGL initialization function. Sets all of the initial parameters. */

View File

@ -156,6 +156,8 @@ void LoadGLTextures() {
GL_TEXTURE_2D, 0, image1->internal_format, image1->sizeX, image1->sizeY, 0,
image1->format, image1->type, image1->data
);
free(image1);
};
/* A general OpenGL initialization function. Sets all of the initial parameters. */

View File

@ -162,6 +162,8 @@ void LoadGLTextures() {
GL_TEXTURE_2D, 0, image1->internalFormat, image1->sizeX, image1->sizeY, 0,
image1->dataSize, image1->data
);
free(image1);
};
/* A general OpenGL initialization function. Sets all of the initial parameters. */

View File

@ -125,6 +125,8 @@ void LoadGLTextures() {
// 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);
glGenerateMipmapEXT(GL_TEXTURE_2D);
free(image1);
}
/* A general OpenGL initialization function. Sets all of the initial parameters. */