From 6b0069ba013236a74be22b30229162b6bfb917b2 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Tue, 27 Oct 2026 20:17:12 +0100 Subject: Turn malloc+memset into calloc --- opentracker.c | 3 +-- ot_vector.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/opentracker.c b/opentracker.c index 065a1ea..eb97b42 100644 --- a/opentracker.c +++ b/opentracker.c @@ -217,11 +217,10 @@ static void handle_accept(const int64_t serversocket) { socket_set_blocking((int)sock, 0); - if (!(cookie = (struct http_data *)malloc(sizeof(struct http_data)))) { + if (!(cookie = (struct http_data *)calloc(1, sizeof(struct http_data)))) { close((int)sock); continue; } - memset(cookie, 0, sizeof(struct http_data)); memcpy(cookie->ip, ip, sizeof(ot_ip6)); cookie->interest = EVENT_IN; diff --git a/ot_vector.c b/ot_vector.c index a56d55b..8310634 100644 --- a/ot_vector.c +++ b/ot_vector.c @@ -208,10 +208,9 @@ void vector_redistribute_buckets(ot_peerlist *peer_list, size_t peer_size) { return; /* Assume near perfect distribution */ - bucket_list_new = malloc(num_buckets_new * sizeof(ot_vector)); + bucket_list_new = calloc(1, num_buckets_new * sizeof(ot_vector)); if (!bucket_list_new) return; - memset(bucket_list_new, 0, num_buckets_new * sizeof(ot_vector)); bucket_size_new = OT_VECTOR_MIN_MEMBERS; while (bucket_size_new * num_buckets_new < peer_list->peer_count) -- cgit v1.3