diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2007-11-21 22:20:44 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2007-11-21 22:20:44 +0000 |
commit | c64cf68244dab6801342d45f78d67a64decc2cae (patch) | |
tree | 5be75be3fdb75eeb3b21eb437702e220ec7bd8df /cmd-list-windows.c | |
parent | 1e5cb8d2e4511be550a409baa9060bbd16f2de0e (diff) | |
download | rtmux-c64cf68244dab6801342d45f78d67a64decc2cae.tar.gz rtmux-c64cf68244dab6801342d45f78d67a64decc2cae.tar.bz2 rtmux-c64cf68244dab6801342d45f78d67a64decc2cae.zip |
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.
Diffstat (limited to 'cmd-list-windows.c')
-rw-r--r-- | cmd-list-windows.c | 23 |
1 files changed, 18 insertions, 5 deletions
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 <nicm@users.sourceforge.net> @@ -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) |