[poppler] 5 commits - glib/poppler-document.cc glib/poppler-page.cc

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Tue Jun 15 05:03:07 PDT 2010


 glib/poppler-document.cc |    9 ++----
 glib/poppler-page.cc     |   67 ++++++++++++++++-------------------------------
 2 files changed, 26 insertions(+), 50 deletions(-)

New commits:
commit f035c94d8b5b34c0c3bb47b8cfc2f9c720a4fc71
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Tue Jun 15 14:01:07 2010 +0200

    [glib] Use g_slice_dup in _copy() function for iterators

diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc
index cd6794a..76a05a1 100644
--- a/glib/poppler-document.cc
+++ b/glib/poppler-document.cc
@@ -967,8 +967,7 @@ poppler_index_iter_copy (PopplerIndexIter *iter)
 
 	g_return_val_if_fail (iter != NULL, NULL);
 
-	new_iter = g_slice_new (PopplerIndexIter);
-	*new_iter = *iter;
+	new_iter = g_slice_dup (PopplerIndexIter, iter);
 	new_iter->document = (PopplerDocument *) g_object_ref (new_iter->document);
 
 	return new_iter;
@@ -1292,8 +1291,7 @@ poppler_fonts_iter_copy (PopplerFontsIter *iter)
 
 	g_return_val_if_fail (iter != NULL, NULL);
 
-	new_iter = g_slice_new (PopplerFontsIter);
-	*new_iter = *iter;
+	new_iter = g_slice_dup (PopplerFontsIter, iter);
 
 	new_iter->items = new GooList ();
 	for (int i = 0; i < iter->items->getLength(); i++) {
@@ -1631,8 +1629,7 @@ poppler_layers_iter_copy (PopplerLayersIter *iter)
 
   g_return_val_if_fail (iter != NULL, NULL);
   
-  new_iter = g_slice_new (PopplerLayersIter);
-  *new_iter = *iter;
+  new_iter = g_slice_dup (PopplerLayersIter, iter);
   new_iter->document = (PopplerDocument *) g_object_ref (new_iter->document);
   
   return new_iter;
commit c84f69681828c7e3b969f666f9b84f1531976c6f
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Tue Jun 15 13:57:18 2010 +0200

    [glib] Use g_slice for mappings and PopplerRectangle

diff --git a/glib/poppler-page.cc b/glib/poppler-page.cc
index 6a3b3ab..14601a6 100644
--- a/glib/poppler-page.cc
+++ b/glib/poppler-page.cc
@@ -1523,26 +1523,21 @@ POPPLER_DEFINE_BOXED_TYPE (PopplerRectangle, poppler_rectangle,
 PopplerRectangle *
 poppler_rectangle_new (void)
 {
-  return g_new0 (PopplerRectangle, 1);
+  return g_slice_new0 (PopplerRectangle);
 }
 
 PopplerRectangle *
 poppler_rectangle_copy (PopplerRectangle *rectangle)
 {
-  PopplerRectangle *new_rectangle;
-
   g_return_val_if_fail (rectangle != NULL, NULL);
-  
-  new_rectangle = g_new (PopplerRectangle, 1);
-  *new_rectangle = *rectangle;
 
-  return new_rectangle;
+  return g_slice_dup (PopplerRectangle, rectangle);
 }
 
 void
 poppler_rectangle_free (PopplerRectangle *rectangle)
 {
-  g_free (rectangle);
+  g_slice_free (PopplerRectangle, rectangle);
 }
 
 /* PopplerColor type */
@@ -1579,7 +1574,7 @@ POPPLER_DEFINE_BOXED_TYPE (PopplerLinkMapping, poppler_link_mapping,
 PopplerLinkMapping *
 poppler_link_mapping_new (void)
 {
-  return (PopplerLinkMapping *) g_new0 (PopplerLinkMapping, 1);
+  return g_slice_new0 (PopplerLinkMapping);
 }
 
 PopplerLinkMapping *
@@ -1587,9 +1582,8 @@ poppler_link_mapping_copy (PopplerLinkMapping *mapping)
 {
   PopplerLinkMapping *new_mapping;
 
-  new_mapping = poppler_link_mapping_new ();
-	
-  *new_mapping = *mapping;
+  new_mapping = g_slice_dup (PopplerLinkMapping, mapping);
+
   if (new_mapping->action)
     new_mapping->action = poppler_action_copy (new_mapping->action);
 
@@ -1602,7 +1596,7 @@ poppler_link_mapping_free (PopplerLinkMapping *mapping)
   if (mapping->action)
     poppler_action_free (mapping->action);
 
-  g_free (mapping);
+  g_slice_free (PopplerLinkMapping, mapping);
 }
 
 /* Poppler Image mapping type */
@@ -1613,25 +1607,19 @@ POPPLER_DEFINE_BOXED_TYPE (PopplerImageMapping, poppler_image_mapping,
 PopplerImageMapping *
 poppler_image_mapping_new (void)
 {
-  return (PopplerImageMapping *) g_new0 (PopplerImageMapping, 1);
+  return g_slice_new0 (PopplerImageMapping);
 }
 
 PopplerImageMapping *
 poppler_image_mapping_copy (PopplerImageMapping *mapping)
 {
-  PopplerImageMapping *new_mapping;
-
-  new_mapping = poppler_image_mapping_new ();
-
-  *new_mapping = *mapping;
-
-  return new_mapping;
+  return g_slice_dup (PopplerImageMapping, mapping);
 }
 
 void
 poppler_image_mapping_free (PopplerImageMapping *mapping)
 {
-  g_free (mapping);
+  g_slice_free (PopplerImageMapping, mapping);
 }
 
 /* Page Transition */
@@ -1670,16 +1658,15 @@ POPPLER_DEFINE_BOXED_TYPE (PopplerFormFieldMapping, poppler_form_field_mapping,
 PopplerFormFieldMapping *
 poppler_form_field_mapping_new (void)
 {
-  return (PopplerFormFieldMapping *) g_new0 (PopplerFormFieldMapping, 1);
+  return g_slice_new0 (PopplerFormFieldMapping);
 }
 
 PopplerFormFieldMapping *
 poppler_form_field_mapping_copy (PopplerFormFieldMapping *mapping)
 {
   PopplerFormFieldMapping *new_mapping;
-  
-  new_mapping = poppler_form_field_mapping_new ();
-  *new_mapping = *mapping;
+
+  new_mapping = g_slice_dup (PopplerFormFieldMapping, mapping);
 
   if (mapping->field)
 	  new_mapping->field = (PopplerFormField *)g_object_ref (mapping->field);
@@ -1695,8 +1682,8 @@ poppler_form_field_mapping_free (PopplerFormFieldMapping *mapping)
 
   if (mapping->field)
     g_object_unref (mapping->field);
-  
-  g_free (mapping);
+
+  g_slice_free (PopplerFormFieldMapping, mapping);
 }
 
 /* PopplerAnnot Mapping Type */
@@ -1707,7 +1694,7 @@ POPPLER_DEFINE_BOXED_TYPE (PopplerAnnotMapping, poppler_annot_mapping,
 PopplerAnnotMapping *
 poppler_annot_mapping_new (void)
 {
-  return (PopplerAnnotMapping *) g_new0 (PopplerAnnotMapping, 1);
+  return g_slice_new0 (PopplerAnnotMapping);
 }
 
 PopplerAnnotMapping *
@@ -1715,9 +1702,8 @@ poppler_annot_mapping_copy (PopplerAnnotMapping *mapping)
 {
   PopplerAnnotMapping *new_mapping;
 
-  new_mapping = poppler_annot_mapping_new ();
+  new_mapping = g_slice_dup (PopplerAnnotMapping, mapping);
 
-  *new_mapping = *mapping;
   if (mapping->annot)
     new_mapping->annot = (PopplerAnnot *) g_object_ref (mapping->annot);
 
@@ -1733,7 +1719,7 @@ poppler_annot_mapping_free (PopplerAnnotMapping *mapping)
   if (mapping->annot)
     g_object_unref (mapping->annot);
 
-  g_free (mapping);
+  g_slice_free (PopplerAnnotMapping, mapping);
 }
 
 void 
commit e12b9ab105f3b56b47ded871693b939ed421c853
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Tue Jun 15 13:49:27 2010 +0200

    [glib] Use poppler_image_mapping_free() instead of g_free()

diff --git a/glib/poppler-page.cc b/glib/poppler-page.cc
index fbfaf98..6a3b3ab 100644
--- a/glib/poppler-page.cc
+++ b/glib/poppler-page.cc
@@ -1140,7 +1140,7 @@ poppler_page_free_image_mapping (GList *list)
   if (list == NULL)
     return;
 
-  g_list_foreach (list, (GFunc)g_free, NULL);
+  g_list_foreach (list, (GFunc)poppler_image_mapping_free, NULL);
   g_list_free (list);
 }
 
commit fb791a15f7472042fb2174e6f5df6924dd4eeb9b
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Tue Jun 15 13:37:52 2010 +0200

    [glib] Remove poppler_mapping_free and use poppler_link_mapping_free instead

diff --git a/glib/poppler-page.cc b/glib/poppler-page.cc
index 77f191a..fbfaf98 100644
--- a/glib/poppler-page.cc
+++ b/glib/poppler-page.cc
@@ -1305,13 +1305,6 @@ poppler_page_get_link_mapping (PopplerPage *page)
   return map_list;
 }
 
-static void
-poppler_mapping_free (PopplerLinkMapping *mapping)
-{
-  poppler_action_free (mapping->action);
-  g_free (mapping);
-}
-
 /**
  * poppler_page_free_link_mapping:
  * @list: A list of #PopplerLinkMapping<!-- -->s
@@ -1327,7 +1320,7 @@ poppler_page_free_link_mapping (GList *list)
   if (list == NULL)
     return;
 
-  g_list_foreach (list, (GFunc) (poppler_mapping_free), NULL);
+  g_list_foreach (list, (GFunc)poppler_link_mapping_free, NULL);
   g_list_free (list);
 }
 
commit 6186d7220e545eb89597626933a10acd0cd25173
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Tue Jun 15 13:16:59 2010 +0200

    [glib] Use _new() methods instead of g_new() to create boxed structs

diff --git a/glib/poppler-page.cc b/glib/poppler-page.cc
index 39645bd..77f191a 100644
--- a/glib/poppler-page.cc
+++ b/glib/poppler-page.cc
@@ -991,7 +991,7 @@ poppler_page_find_text (PopplerPage *page,
 			     gFalse, gFalse, // caseSensitive, backwards
 			     &xMin, &yMin, &xMax, &yMax))
     {
-      match = g_new (PopplerRectangle, 1);
+      match = poppler_rectangle_new ();
       match->x1 = xMin;
       match->y1 = height - yMax;
       match->x2 = xMax;
@@ -1061,7 +1061,7 @@ poppler_page_get_image_mapping (PopplerPage *page)
     image = out->getImage (i);
 
     /* Create the mapping */
-    mapping = g_new (PopplerImageMapping, 1);
+    mapping = poppler_image_mapping_new ();
 
     image->getRect (&(mapping->area.x1), &(mapping->area.y1),
 		    &(mapping->area.x2), &(mapping->area.y2));
@@ -1257,7 +1257,7 @@ poppler_page_get_link_mapping (PopplerPage *page)
       link_action = link->getAction ();
       
       /* Create the mapping */
-      mapping = g_new (PopplerLinkMapping, 1);
+      mapping = poppler_link_mapping_new ();
       mapping->action = _poppler_action_new (page->document, link_action, NULL);
 
       link->getRect (&rect.x1, &rect.y1, &rect.x2, &rect.y2);


More information about the poppler mailing list