[gtk/stringlist-judy: 1/4] Add a way to get the memory consumption of a string list



commit c509bc5f8dfbf5c3b3ef8ed15fab2f99a3590b7c
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jul 5 11:33:26 2020 -0400

    Add a way to get the memory consumption of a string list
    
    This is just for tests, and not meant to be merged.
    I want to be able to compare the data structure size
    for various string list implementations.

 gtk/gtkstringlist.c | 6 ++++++
 gtk/gtkstringlist.h | 3 +++
 2 files changed, 9 insertions(+)
---
diff --git a/gtk/gtkstringlist.c b/gtk/gtkstringlist.c
index 0ddcbf4096..b844d9780a 100644
--- a/gtk/gtkstringlist.c
+++ b/gtk/gtkstringlist.c
@@ -581,3 +581,9 @@ gtk_string_list_get_string (GtkStringList *self,
 
   return objects_get (&self->items, position)->string;
 }
+
+guint64
+gtk_string_list_get_size (GtkStringList *self)
+{
+  return sizeof (GtkStringList) + (self->items.end_allocation - self->items.start) * sizeof (gpointer);
+}
diff --git a/gtk/gtkstringlist.h b/gtk/gtkstringlist.h
index 17be87864b..ef9630901d 100644
--- a/gtk/gtkstringlist.h
+++ b/gtk/gtkstringlist.h
@@ -69,6 +69,9 @@ GDK_AVAILABLE_IN_ALL
 const char *    gtk_string_list_get_string      (GtkStringList         *self,
                                                  guint                  position);
 
+GDK_AVAILABLE_IN_ALL
+guint64         gtk_string_list_get_size        (GtkStringList         *self);
+
 G_END_DECLS
 
 #endif /* __GTK_STRING_LIST_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]