diff options
author | taiyu <taiyu.len@gmail.com> | 2015-08-31 08:49:24 -0700 |
---|---|---|
committer | taiyu <taiyu.len@gmail.com> | 2015-08-31 08:49:24 -0700 |
commit | 09c9ee76c3fbfd5de96cb3c166f268597b436ba0 (patch) | |
tree | b661ce2e2d2cac06294a7a7ac9e84e4ab24abbca /sway/container.c | |
parent | 4d9b05e649ff902c3b53b7e56c0feaa6087f13dc (diff) |
properly remove children in loops
Diffstat (limited to 'sway/container.c')
-rw-r--r-- | sway/container.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/sway/container.c b/sway/container.c index d60aa6ff..442266ec 100644 --- a/sway/container.c +++ b/sway/container.c @@ -35,11 +35,8 @@ static void free_swayc(swayc_t *cont) { list_free(cont->children); } if (cont->floating) { - if (cont->floating->length) { - int i; - for (i = 0; i < cont->floating->length; ++i) { - free_swayc(cont->floating->items[i]); - } + while (cont->floating->length) { + free_swayc(cont->floating->items[0]); } list_free(cont->floating); } @@ -304,16 +301,14 @@ swayc_t *destroy_output(swayc_t *output) { return NULL; } if (output->children->length > 0) { - int i, len = root_container.children->length; // TODO save workspaces when there are no outputs. // TODO also check if there will ever be no outputs except for exiting // program - if (len > 1) { - len = output->children->length; + if (root_container.children->length > 1) { int p = root_container.children->items[0] == output; // Move workspace from this output to another output - for (i = 0; i < len; ++i) { - swayc_t *child = output->children->items[i]; + while (output->children->length) { + swayc_t *child = output->children->items[0]; remove_child(child); add_child(root_container.children->items[p], child); } @@ -651,6 +646,7 @@ void update_visibility(swayc_t *container) { } void reset_gaps(swayc_t *view, void *data) { + (void) data; if (!ASSERT_NONNULL(view)) { return; } |