# HG changeset patch # User Mikael Berthe # Date 1179569905 -7200 # Node ID 79c396678f1b65be69e56b16401f1fbcf71b20f2 # Parent 2521efbf3b7240b8079b67835df3f5a1cb815c92 Make buffer list display the number of allocated HBB blocks diff -r 2521efbf3b72 -r 79c396678f1b mcabber/src/hbuf.c --- 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... */ diff -r 2521efbf3b72 -r 79c396678f1b mcabber/src/hbuf.h --- 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... */ diff -r 2521efbf3b72 -r 79c396678f1b mcabber/src/screen.c --- 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."); }