]> gitweb.michael.orlitzky.com - libsvgtiny-pixbuf.git/blobdiff - io-svg.c
io-svg.c: simplify memory management for context->svg_data
[libsvgtiny-pixbuf.git] / io-svg.c
index 5f57689902e9d3830d799f0646f1b74c4425dfff..543162f6c0b21f8357679f3e03ce76f408e91da9 100644 (file)
--- a/io-svg.c
+++ b/io-svg.c
@@ -131,7 +131,6 @@ static diagram_t* svgtiny_diagram_from_buffer(char* buffer,
   }
 
   code = svgtiny_parse(diagram, buffer, bytecount, "", width, height);
-  free(buffer);
 
   if (code != svgtiny_OK) {
     switch (code) {
@@ -340,8 +339,7 @@ static gpointer gdk_pixbuf_begin_load(GdkPixbufModuleSizeFunc size_func,
   context->updated_func   = updated_func;
   context->user_data      = user_data;
 
-  /* YOLO, no error checking */
-  context->svg_data       = g_malloc(0);
+  context->svg_data       = NULL;
   context->svg_data_size  = 0;
 
   return context;
@@ -381,17 +379,6 @@ static void emit_prepared(SvgTinyContext* context, GdkPixbuf* pixbuf) {
 }
 
 
-/*
-static void emit_size(SvgTinyContext* context, GdkPixbuf* pixbuf) {
-  int w = gdk_pixbuf_get_width(pixbuf);
-  int h = gdk_pixbuf_get_height(pixbuf);
-  if (context->size_func != NULL) {
-    (*context->size_func)(&w, &h, context->user_data);
-  }
-}
-*/
-
-
 static gboolean gdk_pixbuf_stop_load(gpointer data, GError **error) {
   SvgTinyContext* context = (SvgTinyContext*)data;
   GdkPixbuf* pixbuf = NULL;
@@ -403,7 +390,6 @@ static gboolean gdk_pixbuf_stop_load(gpointer data, GError **error) {
                                       &sub_error);
 
   if (pixbuf != NULL) {
-    /*emit_size(context, pixbuf);*/
     emit_prepared(context, pixbuf);
     emit_updated(context, pixbuf);
     g_object_unref(pixbuf);
@@ -412,6 +398,7 @@ static gboolean gdk_pixbuf_stop_load(gpointer data, GError **error) {
     g_propagate_error(error, sub_error);
     result = FALSE;
   }
+  g_free(context->svg_data);
   g_free(context);
 
   return result;