summaryrefslogtreecommitdiff
path: root/trackerlogic.c
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-10-23 21:48:58 +0200
committerDirk Engling <erdgeist@erdgeist.org>2026-10-23 21:48:58 +0200
commitde67a4a721c0fda9a9b5955f235baafba9ba393d (patch)
tree38627ee2df6927e715e7043809d281b16abdbddc /trackerlogic.c
parenta8def0e5eac98500267b52c7f0d9a7fbc2145a81 (diff)
Rework config file parser and tidy up mem inits
Diffstat (limited to 'trackerlogic.c')
-rw-r--r--trackerlogic.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/trackerlogic.c b/trackerlogic.c
index 7c6b7e1..94ec71a 100644
--- a/trackerlogic.c
+++ b/trackerlogic.c
@@ -14,7 +14,6 @@
14 14
15/* Libowfat */ 15/* Libowfat */
16#include "array.h" 16#include "array.h"
17#include "byte.h"
18#include "io.h" 17#include "io.h"
19#include "iob.h" 18#include "iob.h"
20#include "ip6.h" 19#include "ip6.h"
@@ -57,7 +56,7 @@ void add_torrent_from_saved_state(ot_hash const hash, ot_time base, size_t down_
57 return mutex_bucket_unlock_by_hash(hash, 0); 56 return mutex_bucket_unlock_by_hash(hash, 0);
58 57
59 /* Create a new torrent entry, then */ 58 /* Create a new torrent entry, then */
60 byte_zero(torrent, sizeof(ot_torrent)); 59 memset(torrent, 0, sizeof(ot_torrent));
61 memcpy(torrent->hash, hash, sizeof(ot_hash)); 60 memcpy(torrent->hash, hash, sizeof(ot_hash));
62 61
63 if (!(torrent->peer_list6 = malloc(sizeof(ot_peerlist))) || !(torrent->peer_list4 = malloc(sizeof(ot_peerlist)))) { 62 if (!(torrent->peer_list6 = malloc(sizeof(ot_peerlist))) || !(torrent->peer_list4 = malloc(sizeof(ot_peerlist)))) {
@@ -65,8 +64,8 @@ void add_torrent_from_saved_state(ot_hash const hash, ot_time base, size_t down_
65 return mutex_bucket_unlock_by_hash(hash, 0); 64 return mutex_bucket_unlock_by_hash(hash, 0);
66 } 65 }
67 66
68 byte_zero(torrent->peer_list6, sizeof(ot_peerlist)); 67 memset(torrent->peer_list6, 0, sizeof(ot_peerlist));
69 byte_zero(torrent->peer_list4, sizeof(ot_peerlist)); 68 memset(torrent->peer_list4, 0, sizeof(ot_peerlist));
70 torrent->peer_list6->base = base; 69 torrent->peer_list6->base = base;
71 torrent->peer_list4->base = base; 70 torrent->peer_list4->base = base;
72 torrent->peer_list6->down_count = down_count; 71 torrent->peer_list6->down_count = down_count;
@@ -102,7 +101,7 @@ size_t add_peer_to_torrent_and_return_peers(PROTO_FLAG proto, struct ot_workstru
102 101
103 if (!exactmatch) { 102 if (!exactmatch) {
104 /* Create a new torrent entry, then */ 103 /* Create a new torrent entry, then */
105 byte_zero(torrent, sizeof(ot_torrent)); 104 memset(torrent, 0, sizeof(ot_torrent));
106 memcpy(torrent->hash, *ws->hash, sizeof(ot_hash)); 105 memcpy(torrent->hash, *ws->hash, sizeof(ot_hash));
107 106
108 if (!(torrent->peer_list6 = malloc(sizeof(ot_peerlist))) || !(torrent->peer_list4 = malloc(sizeof(ot_peerlist)))) { 107 if (!(torrent->peer_list6 = malloc(sizeof(ot_peerlist))) || !(torrent->peer_list4 = malloc(sizeof(ot_peerlist)))) {
@@ -111,8 +110,8 @@ size_t add_peer_to_torrent_and_return_peers(PROTO_FLAG proto, struct ot_workstru
111 return 0; 110 return 0;
112 } 111 }
113 112
114 byte_zero(torrent->peer_list6, sizeof(ot_peerlist)); 113 memset(torrent->peer_list6, 0, sizeof(ot_peerlist));
115 byte_zero(torrent->peer_list4, sizeof(ot_peerlist)); 114 memset(torrent->peer_list4, 0, sizeof(ot_peerlist));
116 delta_torrentcount = 1; 115 delta_torrentcount = 1;
117 } else 116 } else
118 clean_single_torrent(torrent); 117 clean_single_torrent(torrent);