summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémie Courrèges-Anglas <jca@wxcvbn.org>2014-03-04 02:49:35 +0100
committerJérémie Courrèges-Anglas <jca@wxcvbn.org>2014-03-04 02:49:35 +0100
commit710696420f50234716579c98367696a43a211482 (patch)
tree448c494ccbf3653f7acbcb1af5d05efc59329ee7
parent5dcd243c55447099e4ff353fafbbad2a02836b0c (diff)
downloadratpoison-710696420f50234716579c98367696a43a211482.zip
Simplify list_unmanaged_windows using sbuf
-rw-r--r--src/manage.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/manage.c b/src/manage.c
index 5a9a9d8..f54c63a 100644
--- a/src/manage.c
+++ b/src/manage.c
@@ -57,25 +57,21 @@ char *
list_unmanaged_windows (void)
{
char *tmp = NULL;
+
if (unmanaged_window_list)
{
- char *tpos;
- int len = 0;
+ struct sbuf *buf;
int i;
- for (i = 0; i < num_unmanaged_windows; i++)
- len += (strlen(unmanaged_window_list[i]) + 1);
-
- tmp = xmalloc(len + 1);
- tpos = tmp;
+ buf = sbuf_new (0);
for (i = 0; i < num_unmanaged_windows; i++)
{
- sprintf(tpos, "%s\n", unmanaged_window_list[i]);
- tpos += strlen(unmanaged_window_list[i])+1;
+ sbuf_concat (buf, unmanaged_window_list[i]);
+ sbuf_concat (buf, "\n");
}
- tpos--;
- *tpos = '\0';
+ sbuf_chop (buf);
+ tmp = sbuf_free_struct (buf);
}
return tmp;
}