From c64cf68244dab6801342d45f78d67a64decc2cae Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 21 Nov 2007 22:20:44 +0000 Subject: Cut memory consumption by only allocating lines when there is actually data on them, and only as much as the right-most data. Everything else is filled in at runtime. --- cmd-list-windows.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'cmd-list-windows.c') diff --git a/cmd-list-windows.c b/cmd-list-windows.c index c2a5e09a..74840b84 100644 --- a/cmd-list-windows.c +++ b/cmd-list-windows.c @@ -1,4 +1,4 @@ -/* $Id: cmd-list-windows.c,v 1.10 2007-11-21 13:11:41 nicm Exp $ */ +/* $Id: cmd-list-windows.c,v 1.11 2007-11-21 22:20:44 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -42,15 +42,28 @@ const struct cmd_entry cmd_list_windows_entry = { void cmd_list_windows_exec(unused void *ptr, struct cmd_ctx *ctx) { - struct winlink *wl; - struct window *w; + struct winlink *wl; + struct window *w; + u_int i, sy; + unsigned long long size; RB_FOREACH(wl, winlinks, &ctx->session->windows) { w = wl->window; - ctx->print(ctx, "%d: %s \"%s\" (%s) [%ux%u] [history %u]", + + sy = w->screen.hsize + w->screen.dy; + size = sizeof *w; + for (i = 0; i < sy; i++) + size += 4 + w->screen.grid_size[i] * 3; + size += sy * (sizeof *w->screen.grid_data); + size += sy * (sizeof *w->screen.grid_attr); + size += sy * (sizeof *w->screen.grid_colr); + size += sy * (sizeof *w->screen.grid_size); + + ctx->print(ctx, + "%d: %s \"%s\" (%s) [%ux%u] [history %u] [%llu bytes]", wl->idx, w->name, w->screen.title, ttyname(w->fd), screen_size_x(&w->screen), screen_size_y(&w->screen), - w->screen.hsize); + w->screen.hsize, size); } if (ctx->cmdclient != NULL) -- cgit v1.2.3