Commit 80fbda05 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

removed gimp_g_object_get_memsize()...

2003-11-25  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpobject.[ch]: removed gimp_g_object_get_memsize()...

	* app/core/gimp-utils.[ch]: ...and added it here along with
	some other memsize utilities for GHashTables and G(S)Lists.

	* app/core/gimp.c
	* app/core/gimpimage.c
	* app/core/gimpparasitelist.c
	* app/core/gimpviewable.c
	* app/vectors/gimpstroke.c (GimpObject::get_memsize): use the new
	functions.
parent afd493a3
2003-11-25 Michael Natterer <mitch@gimp.org>
* app/core/gimpobject.[ch]: removed gimp_g_object_get_memsize()...
* app/core/gimp-utils.[ch]: ...and added it here along with
some other memsize utilities for GHashTables and G(S)Lists.
* app/core/gimp.c
* app/core/gimpimage.c
* app/core/gimpparasitelist.c
* app/core/gimpviewable.c
* app/vectors/gimpstroke.c (GimpObject::get_memsize): use the new
functions.
2003-11-22 Dave Neary <bolsh@gimp.org>
 
* libgimp/Makefile.am: Applied patch from deaddog@deaddog.org (Abel
......@@ -55,3 +55,41 @@ gimp_rectangle_intersect (gint x1,
return (d_w > 0 && d_h > 0);
}
gint64
gimp_g_object_get_memsize (GObject *object)
{
GTypeQuery type_query;
gint64 memsize = 0;
g_return_val_if_fail (G_IS_OBJECT (object), 0);
g_type_query (G_TYPE_FROM_INSTANCE (object), &type_query);
memsize += type_query.instance_size;
return memsize;
}
gint64
gimp_g_hash_table_get_memsize (GHashTable *hash)
{
g_return_val_if_fail (hash != NULL, 0);
return (2 * sizeof (gint) +
5 * sizeof (gpointer) +
g_hash_table_size (hash) * 3 * sizeof (gpointer));
}
gint64
gimp_g_slist_get_memsize (GSList *slist,
gint64 data_size)
{
return g_slist_length (slist) * (data_size + sizeof (GSList));
}
gint64
gimp_g_list_get_memsize (GList *list,
gint64 data_size)
{
return g_list_length (list) * (data_size + sizeof (GList));
}
......@@ -20,18 +20,25 @@
#define __APP_GIMP_UTILS_H__
gboolean gimp_rectangle_intersect (gint x1,
gint y1,
gint width1,
gint height1,
gint x2,
gint y2,
gint width2,
gint height2,
gint *dest_x,
gint *dest_y,
gint *dest_width,
gint *dest_height);
gboolean gimp_rectangle_intersect (gint x1,
gint y1,
gint width1,
gint height1,
gint x2,
gint y2,
gint width2,
gint height2,
gint *dest_x,
gint *dest_y,
gint *dest_width,
gint *dest_height);
gint64 gimp_g_object_get_memsize (GObject *object);
gint64 gimp_g_hash_table_get_memsize (GHashTable *hash);
gint64 gimp_g_slist_get_memsize (GSList *slist,
gint64 data_size);
gint64 gimp_g_list_get_memsize (GList *list,
gint64 data_size);
#endif /* __APP_GIMP_UTILS_H__ */
......@@ -49,6 +49,7 @@
#include "gimp-parasites.h"
#include "gimp-templates.h"
#include "gimp-units.h"
#include "gimp-utils.h"
#include "gimpbrush.h"
#include "gimpbrushgenerated.h"
#include "gimpbrushpipe.h"
......@@ -493,17 +494,15 @@ gimp_get_memsize (GimpObject *object,
gimp = GIMP (object);
memsize += g_list_length (gimp->user_units) * sizeof (GList); /* FIXME */
memsize += gimp_g_list_get_memsize (gimp->user_units, 0 /* FIXME */);
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->parasites),
gui_size);
memsize += gimp_g_object_get_memsize (G_OBJECT (gimp->module_db));
memsize += (g_hash_table_size (gimp->image_table) *
3 * sizeof (gpointer)); /* FIXME */
memsize += (g_hash_table_size (gimp->item_table) *
3 * sizeof (gpointer)); /* FIXME */
memsize += gimp_g_hash_table_get_memsize (gimp->image_table);
memsize += gimp_g_hash_table_get_memsize (gimp->item_table);
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->displays), gui_size);
......@@ -524,14 +523,13 @@ gimp_get_memsize (GimpObject *object,
gimp_object_get_memsize (GIMP_OBJECT (gimp->palette_factory),
gui_size));
memsize += (g_hash_table_size (gimp->procedural_ht) *
3 * sizeof (gpointer)); /* FIXME */
memsize += gimp_g_hash_table_get_memsize (gimp->procedural_ht);
memsize += (g_list_length (gimp->procedural_db_data_list) *
sizeof (GList)); /* FIXME */
memsize += gimp_g_list_get_memsize (gimp->procedural_db_data_list,
0 /* FIXME */);
memsize += g_slist_length (gimp->load_procs) * sizeof (GSList); /* FIXME */
memsize += g_slist_length (gimp->save_procs) * sizeof (GSList); /* FIXME */
memsize += gimp_g_slist_get_memsize (gimp->load_procs, 0 /* FIXME */);
memsize += gimp_g_slist_get_memsize (gimp->save_procs, 0 /* FIXME */);
memsize += (gimp_object_get_memsize (GIMP_OBJECT (gimp->tool_info_list),
gui_size) +
......@@ -544,7 +542,7 @@ gimp_get_memsize (GimpObject *object,
gimp_object_get_memsize (GIMP_OBJECT (gimp->image_new_last_template),
gui_size));
memsize += g_list_length (gimp->context_list) * sizeof (GList);
memsize += gimp_g_list_get_memsize (gimp->context_list, 0);
memsize += (gimp_object_get_memsize (GIMP_OBJECT (gimp->standard_context),
gui_size) +
......
......@@ -37,6 +37,7 @@
#include "gimp.h"
#include "gimp-parasites.h"
#include "gimp-utils.h"
#include "gimpcontext.h"
#include "gimpgrid.h"
#include "gimpimage.h"
......@@ -705,8 +706,7 @@ gimp_image_get_memsize (GimpObject *object,
if (gimage->projection)
memsize += tile_manager_get_memsize (gimage->projection);
memsize += (g_list_length (gimage->guides) * (sizeof (GList) +
sizeof (GimpGuide)));
memsize += gimp_g_list_get_memsize (gimage->guides, sizeof (GimpGuide));
if (gimage->grid)
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimage->grid), gui_size);
......@@ -718,7 +718,7 @@ gimp_image_get_memsize (GimpObject *object,
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimage->vectors),
gui_size);
memsize += g_slist_length (gimage->layer_stack) * sizeof (GSList);
memsize += gimp_g_slist_get_memsize (gimage->layer_stack, 0);
if (gimage->selection_mask)
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimage->selection_mask),
......
......@@ -26,6 +26,7 @@
#include "core-types.h"
#include "gimp-utils.h"
#include "gimpmarshal.h"
#include "gimpobject.h"
......@@ -446,21 +447,6 @@ gimp_object_get_memsize (GimpObject *object,
return my_size;
}
gint64
gimp_g_object_get_memsize (GObject *object)
{
GTypeQuery type_query;
gint64 memsize = 0;
g_return_val_if_fail (G_IS_OBJECT (object), 0);
g_type_query (G_TYPE_FROM_INSTANCE (object), &type_query);
memsize += type_query.instance_size;
return memsize;
}
static gint64
gimp_object_real_get_memsize (GimpObject *object,
gint64 *gui_size)
......
......@@ -68,7 +68,6 @@ gint gimp_object_name_collate (GimpObject *object1,
GimpObject *object2);
gint64 gimp_object_get_memsize (GimpObject *object,
gint64 *gui_size);
gint64 gimp_g_object_get_memsize (GObject *object);
#endif /* __GIMP_OBJECT_H__ */
......@@ -36,6 +36,7 @@
#include "config/gimpconfigwriter.h"
#include "config/gimpscanner.h"
#include "gimp-utils.h"
#include "gimpmarshal.h"
#include "gimpparasitelist.h"
......@@ -218,8 +219,7 @@ gimp_parasite_list_get_memsize (GimpObject *object,
if (list->table)
{
/* FIXME */
memsize += (g_hash_table_size (list->table) * 3 * sizeof (gpointer));
memsize += gimp_g_hash_table_get_memsize (list->table);
g_hash_table_foreach (list->table,
gimp_parasite_list_get_memsize_foreach,
......
......@@ -33,6 +33,7 @@
#include "config/gimpconfig-params.h"
#include "config/gimpconfigwriter.h"
#include "gimp-utils.h"
#include "gimpmarshal.h"
#include "gimpviewable.h"
......
......@@ -25,6 +25,8 @@
#include "vectors-types.h"
#include "core/gimp-utils.h"
#include "gimpanchor.h"
#include "gimpstroke.h"
......@@ -371,8 +373,7 @@ gimp_stroke_get_memsize (GimpObject *object,
stroke = GIMP_STROKE (object);
memsize += g_list_length (stroke->anchors) * (sizeof (GList) +
sizeof (GimpAnchor));
memsize += gimp_g_list_get_memsize (stroke->anchors, sizeof (GimpAnchor));
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object,
gui_size);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment