aboutsummaryrefslogtreecommitdiff
path: root/seatd/server.c
diff options
context:
space:
mode:
authorKenny Levinsen <kl@kl.wtf>2020-08-31 01:34:36 +0200
committerKenny Levinsen <kl@kl.wtf>2020-08-31 14:09:59 +0200
commitd75b617fafa41b83aab5943827224df8b7ff9e4a (patch)
tree747d1b9363c50a7aecbb895e7bb325e2f30f3307 /seatd/server.c
parent7d88315fea1448fc3f0e33c7a8a00ec12458b473 (diff)
server: Convert seat list to linked_list
Diffstat (limited to 'seatd/server.c')
-rw-r--r--seatd/server.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/seatd/server.c b/seatd/server.c
index 7368ea3..4562a71 100644
--- a/seatd/server.c
+++ b/seatd/server.c
@@ -12,7 +12,6 @@
#include <unistd.h>
#include "client.h"
-#include "list.h"
#include "log.h"
#include "poller.h"
#include "seat.h"
@@ -26,7 +25,7 @@ static int server_handle_kill(int signal, void *data);
int server_init(struct server *server) {
poller_init(&server->poller);
- list_init(&server->seats);
+ linked_list_init(&server->seats);
if (poller_add_signal(&server->poller, SIGUSR1, server_handle_vt_rel, server) == NULL ||
poller_add_signal(&server->poller, SIGUSR2, server_handle_vt_acq, server) == NULL ||
@@ -45,24 +44,24 @@ int server_init(struct server *server) {
return -1;
}
- list_add(&server->seats, seat);
+ linked_list_insert(&server->seats, &seat->link);
server->running = true;
return 0;
}
void server_finish(struct server *server) {
assert(server);
- for (size_t idx = 0; idx < server->seats.length; idx++) {
- struct seat *seat = server->seats.items[idx];
+ while (!linked_list_empty(&server->seats)) {
+ struct seat *seat = (struct seat *)server->seats.next;
seat_destroy(seat);
}
- list_free(&server->seats);
poller_finish(&server->poller);
}
struct seat *server_get_seat(struct server *server, const char *seat_name) {
- for (size_t idx = 0; idx < server->seats.length; idx++) {
- struct seat *seat = server->seats.items[idx];
+ for (struct linked_list *elem = server->seats.next; elem != &server->seats;
+ elem = elem->next) {
+ struct seat *seat = (struct seat *)elem;
if (strcmp(seat->seat_name, seat_name) == 0) {
return seat;
}