[cogl] cogl-primitives: Plug some leaks in cogl_polygon
- From: Neil Roberts <nroberts src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl] cogl-primitives: Plug some leaks in cogl_polygon
- Date: Mon, 1 Aug 2011 13:31:40 +0000 (UTC)
commit bbbe6db2847f36e0a8f26ffbaecced7451a84471
Author: Neil Roberts <neil linux intel com>
Date: Fri Jul 29 17:24:10 2011 +0100
cogl-primitives: Plug some leaks in cogl_polygon
cogl_polygon creates some temporary strings, CoglAttributeBuffers and
CoglAttributes but it was never freeing them.
Based on a patch by Florian Renaut
https://bugzilla.gnome.org/show_bug.cgi?id=655556
Reviewed-by: Robert Bragg <robert linux intel com>
cogl/cogl-primitives.c | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/cogl/cogl-primitives.c b/cogl/cogl-primitives.c
index 69cb71e..cf0720b 100644
--- a/cogl/cogl-primitives.c
+++ b/cogl/cogl-primitives.c
@@ -1086,7 +1086,7 @@ cogl_polygon (const CoglTextureVertex *vertices,
for (i = 0; i < n_layers; i++)
{
- const char *names[] = {
+ static const char *names[] = {
"cogl_tex_coord0_in",
"cogl_tex_coord1_in",
"cogl_tex_coord2_in",
@@ -1096,8 +1096,13 @@ cogl_polygon (const CoglTextureVertex *vertices,
"cogl_tex_coord6_in",
"cogl_tex_coord7_in"
};
- char *name = i < 8 ? (char *)names[i] :
- g_strdup_printf ("cogl_tex_coord%d_in", i);
+ char *allocated_name = NULL;
+ const char *name;
+
+ if (i < 8)
+ name = names[i];
+ else
+ name = allocated_name = g_strdup_printf ("cogl_tex_coord%d_in", i);
attributes[i + 1] = cogl_attribute_new (attribute_buffer,
name,
@@ -1106,6 +1111,8 @@ cogl_polygon (const CoglTextureVertex *vertices,
12 + 8 * i,
2,
COGL_ATTRIBUTE_TYPE_FLOAT);
+
+ g_free (allocated_name);
}
if (use_color)
@@ -1170,5 +1177,9 @@ cogl_polygon (const CoglTextureVertex *vertices,
if (pipeline != validate_state.original_pipeline)
cogl_object_unref (pipeline);
-}
+ cogl_object_unref (attribute_buffer);
+
+ for (i = 0; i < n_attributes; i++)
+ cogl_object_unref (attributes[i]);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]