changeset 1227:79c396678f1b

Make buffer list display the number of allocated HBB blocks
author Mikael Berthe <mikael@lilotux.net>
date Sat, 19 May 2007 12:18:25 +0200
parents 2521efbf3b72
children 9a68fe4515dc
files mcabber/src/hbuf.c mcabber/src/hbuf.h mcabber/src/screen.c
diffstat 3 files changed, 28 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/src/hbuf.c	Sat May 19 11:56:32 2007 +0200
+++ b/mcabber/src/hbuf.c	Sat May 19 12:18:25 2007 +0200
@@ -395,4 +395,21 @@
   return g_list_nth(hbuf, pc*hlen/100);
 }
 
+#ifdef DEBUG_ENABLE
+//  hbuf_get_blocks_number()
+// Returns the number of allocated hbuf_block's.
+guint hbuf_get_blocks_number(GList *hbuf)
+{
+  hbuf_block *hbuf_b_elt;
+  guint count = 0U;
+
+  for (hbuf = g_list_first(hbuf); hbuf; hbuf = g_list_next(hbuf)) {
+    hbuf_b_elt = (hbuf_block*)(hbuf->data);
+    if (hbuf_b_elt->flags & HBB_FLAG_ALLOC)
+      count++;
+  }
+  return count;
+}
+#endif
+
 /* vim: set expandtab cindent cinoptions=>2\:2(0:  For Vim users... */
--- a/mcabber/src/hbuf.h	Sat May 19 11:56:32 2007 +0200
+++ b/mcabber/src/hbuf.h	Sat May 19 12:18:25 2007 +0200
@@ -44,6 +44,10 @@
 GList *hbuf_jump_date(GList *hbuf, time_t t);
 GList *hbuf_jump_percent(GList *hbuf, int pc);
 
+#ifdef DEBUG_ENABLE
+guint hbuf_get_blocks_number(GList *p_hbuf);
+#endif
+
 #endif /* __HBUF_H__ */
 
 /* vim: set expandtab cindent cinoptions=>2\:2(0:  For Vim users... */
--- a/mcabber/src/screen.c	Sat May 19 11:56:32 2007 +0200
+++ b/mcabber/src/screen.c	Sat May 19 12:18:25 2007 +0200
@@ -2132,16 +2132,19 @@
 // data: none.
 static void buffer_list(gpointer key, gpointer value, gpointer data)
 {
+  GList *head;
   winbuf *win_entry = value;
-  scr_LogPrint(LPRINT_NORMAL, " %s  (%ld)", key,
-               g_list_length(g_list_first(win_entry->bd->hbuf)));
+
+  head = g_list_first(win_entry->bd->hbuf);
+
+  scr_LogPrint(LPRINT_NORMAL, " %s  (%u/%u)", key,
+               g_list_length(head), hbuf_get_blocks_number(head));
 }
 
 void scr_BufferList(void)
 {
   scr_LogPrint(LPRINT_NORMAL, "Buffer list:");
-  scr_LogPrint(LPRINT_NORMAL, " [status]  (%ld)",
-               g_list_length(g_list_first(statusWindow->bd->hbuf)));
+  buffer_list("[status]", statusWindow, NULL);
   g_hash_table_foreach(winbufhash, buffer_list, NULL);
   scr_LogPrint(LPRINT_NORMAL, "End of buffer list.");
 }