Skip to content

Commit

Permalink
fix -Wclass-memaccess warning
Browse files Browse the repository at this point in the history
likely generates the exact same code.

Reference: rakshasa/libtorrent#280
  • Loading branch information
stickz committed Dec 22, 2024
1 parent faede8a commit 33495c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions libtorrent/rak/partial_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#ifndef RAK_PARTIAL_QUEUE_H
#define RAK_PARTIAL_QUEUE_H

#include <array>
#include <cstring>
#include <stdexcept>
#include <inttypes.h>
Expand Down Expand Up @@ -107,7 +108,7 @@ class partial_queue {
size_type m_index;
size_type m_ceiling;

size_pair_type m_layers[num_layers];
std::array<size_pair_type, num_layers> m_layers;
};

inline void
Expand Down Expand Up @@ -137,7 +138,7 @@ partial_queue::clear() {
m_index = 0;
m_ceiling = ceiling(num_layers - 1);

std::memset(m_layers, 0, num_layers * sizeof(size_pair_type));
m_layers = {};
}

inline bool
Expand Down
5 changes: 3 additions & 2 deletions rtorrent/rak/partial_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#ifndef RAK_PARTIAL_QUEUE_H
#define RAK_PARTIAL_QUEUE_H

#include <array>
#include <cstring>
#include <stdexcept>
#include <inttypes.h>
Expand Down Expand Up @@ -107,7 +108,7 @@ class partial_queue {
size_type m_index;
size_type m_ceiling;

size_pair_type m_layers[num_layers];
std::array<size_pair_type, num_layers> m_layers;
};

inline void
Expand Down Expand Up @@ -137,7 +138,7 @@ partial_queue::clear() {
m_index = 0;
m_ceiling = ceiling(num_layers - 1);

std::memset(m_layers, 0, num_layers * sizeof(size_pair_type));
m_layers = {};
}

inline bool
Expand Down

0 comments on commit 33495c4

Please sign in to comment.