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.
This commit is contained in:
Matthias Clasen
2020-07-05 11:33:26 -04:00
parent c0457fc23b
commit c509bc5f8d
2 changed files with 9 additions and 0 deletions

View File

@@ -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);
}

View File

@@ -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__ */