commit aec47b823880c7dc80f63569103e29c5ebca2f22
parent 4d9b05e649ff902c3b53b7e56c0feaa6087f13dc
Author: Drew DeVault <sir@cmpwn.com>
Date: Mon, 31 Aug 2015 11:55:12 -0400
Merge pull request #158 from taiyu-len/master
properly remove children in loops
Diffstat:
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git 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;
}