diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-04-19 20:00:36 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-04-19 20:00:36 +0200 |
commit | 6798a76ffa1b4de4ec0ea07286c3510d86c0e3b6 (patch) | |
tree | a755a36afca70baaab878d391341129eb95e0873 /src/send.c | |
parent | 2e14d72936d1ccfb6faed4a20dec7072fb6d8232 (diff) | |
download | fastd-6798a76ffa1b4de4ec0ea07286c3510d86c0e3b6.tar fastd-6798a76ffa1b4de4ec0ea07286c3510d86c0e3b6.zip |
Store peers as vectors of pointers instead of linked lists
Diffstat (limited to 'src/send.c')
-rw-r--r-- | src/send.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -177,13 +177,14 @@ void fastd_send_handshake(fastd_context_t *ctx, const fastd_socket_t *sock, cons } void fastd_send_all(fastd_context_t *ctx, fastd_peer_t *source_peer, fastd_buffer_t buffer) { - fastd_peer_t *dest_peer; - for (dest_peer = ctx->peers; dest_peer; dest_peer = dest_peer->next) { + size_t i; + for (i = 0; i < VECTOR_LEN(ctx->peers); i++) { + fastd_peer_t *dest_peer = VECTOR_INDEX(ctx->peers, i); if (dest_peer == source_peer || !fastd_peer_is_established(dest_peer)) continue; /* optimization, primarily for TUN mode: don't duplicate the buffer for the last (or only) peer */ - if (!dest_peer->next) { + if (i == VECTOR_LEN(ctx->peers)-1) { ctx->conf->protocol->send(ctx, dest_peer, buffer); return; } |