commit de5196dc1e6427d76d93d9cafe147fedbffbaad4
parent d2e1c660b19e8bb24e496b3dd52d4696456863f0
Author: taiyu <taiyu.len@gmail.com>
Date: Fri, 21 Aug 2015 12:19:29 -0700
comments + fixed leak
Diffstat:
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/sway/container.c b/sway/container.c
@@ -26,14 +26,11 @@ static void free_swayc(swayc_t *cont) {
if (!ASSERT_NONNULL(cont)) {
return;
}
- // TODO does not properly handle containers with children,
- // TODO but functions that call this usually check for that
if (cont->children) {
- if (cont->children->length) {
- int i;
- for (i = 0; i < cont->children->length; ++i) {
- free_swayc(cont->children->items[i]);
- }
+ // remove children until there are no more, free_swayc calls
+ // remove_child, which removes child from this container
+ while (cont->children->length) {
+ free_swayc(cont->children->items[0]);
}
list_free(cont->children);
}
@@ -409,9 +406,13 @@ swayc_t *swayc_active_workspace_for(swayc_t *cont) {
return NULL;
}
switch (cont->type) {
+ /* set root -> output */
case C_ROOT: cont = cont->focused;
+ /* set output -> workspace */
case C_OUTPUT: cont = cont->focused;
+ /* return workspace */
case C_WORKSPACE: return cont;
+ /* Find parent workspace */
default: return swayc_parent_by_type(cont, C_WORKSPACE);
}
}