diff options
author | Neil Roberts <neil@linux.intel.com> | 2011-07-29 17:24:10 +0100 |
---|---|---|
committer | Neil Roberts <neil@linux.intel.com> | 2011-08-01 14:08:46 +0100 |
commit | bbbe6db2847f36e0a8f26ffbaecced7451a84471 (patch) | |
tree | 522ec4f06c46db2ed69b8b57679f3c4280ad7c5d | |
parent | 38deb97478ace8a3fa19fe55f0a987a2ad6599d0 (diff) | |
download | cogl-bbbe6db2847f36e0a8f26ffbaecced7451a84471.tar.gz |
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>
-rw-r--r-- | 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 69cb71ed..cf0720bc 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]); +} |