aboutsummaryrefslogtreecommitdiff
path: root/swaynag
diff options
context:
space:
mode:
authorIan Fan <ianfan0@gmail.com>2018-12-08 23:55:14 +0000
committerIan Fan <ianfan0@gmail.com>2018-12-09 01:15:38 +0000
commitc8776fac4232f9faab0a78ef3e18dc4366496421 (patch)
tree028fbc584d233a7a934feb0b6807c9a988c8e7f1 /swaynag
parent19e831ed3da2aba75d56e46c57967bcc60442d57 (diff)
Cleanup list code
Diffstat (limited to 'swaynag')
-rw-r--r--swaynag/swaynag.c5
-rw-r--r--swaynag/types.c6
2 files changed, 4 insertions, 7 deletions
diff --git a/swaynag/swaynag.c b/swaynag/swaynag.c
index a2a0b412..e6dfd25f 100644
--- a/swaynag/swaynag.c
+++ b/swaynag/swaynag.c
@@ -407,9 +407,8 @@ void swaynag_destroy(struct swaynag *swaynag) {
swaynag->run_display = false;
free(swaynag->message);
- while (swaynag->buttons->length) {
- struct swaynag_button *button = swaynag->buttons->items[0];
- list_del(swaynag->buttons, 0);
+ for (int i = 0; i < swaynag->buttons->length; ++i) {
+ struct swaynag_button *button = swaynag->buttons->items[i];
free(button->text);
free(button->action);
free(button);
diff --git a/swaynag/types.c b/swaynag/types.c
index 129644b7..bc17bd33 100644
--- a/swaynag/types.c
+++ b/swaynag/types.c
@@ -147,10 +147,8 @@ void swaynag_type_free(struct swaynag_type *type) {
}
void swaynag_types_free(list_t *types) {
- while (types->length) {
- struct swaynag_type *type = types->items[0];
- swaynag_type_free(type);
- list_del(types, 0);
+ for (int i = 0; i < types->length; ++i) {
+ swaynag_type_free(types->items[i]);
}
list_free(types);
}