ソースを参照

Cleanup for defines

Tatsuhiro Tsujikawa 10 年 前
コミット
8ba9b04747
4 ファイル変更8 行追加11 行削除
  1. 1 1
      src/DHTNode.cc
  2. 1 1
      src/PeerConnection.h
  3. 4 7
      src/Platform.cc
  4. 2 2
      src/SingleFileAllocationIterator.cc

+ 1 - 1
src/DHTNode.cc

@@ -89,7 +89,7 @@ bool DHTNode::isGood() const
   return !isBad() && !isQuestionable();
 }
 
-#define BAD_CONDITION 5
+constexpr int BAD_CONDITION = 5;
 
 bool DHTNode::isBad() const
 {

+ 1 - 1
src/PeerConnection.h

@@ -52,7 +52,7 @@ class ARC4Encryptor;
 // The maximum length of buffer. If the message length (including 4
 // bytes length and payload length) is larger than this value, it is
 // dropped.
-#define MAX_BUFFER_CAPACITY (16*1024+128)
+constexpr size_t MAX_BUFFER_CAPACITY = 16 * 1024 + 128;
 
 class PeerConnection {
 private:

+ 4 - 7
src/Platform.cc

@@ -72,10 +72,10 @@
 #endif // HAVE_LIBGMP
 #include "LogFactory.h"
 
-#define A2_MIN_GCRYPT_VERSION "1.2.4"
+namespace aria2 {
 
-namespace {
 #ifdef HAVE_LIBGNUTLS
+namespace {
   void gnutls_log_callback(int level, const char *str)
   {
     using namespace aria2;
@@ -84,11 +84,8 @@ namespace {
     msg.resize(msg.size() - 1);
     A2_LOG_DEBUG(fmt("GnuTLS: <%d> %s", level, msg.c_str()));
   }
-#endif // HAVE_LIBGNUTLS
 }
-
-
-namespace aria2 {
+#endif // HAVE_LIBGNUTLS
 
 bool Platform::initialized_ = false;
 
@@ -126,7 +123,7 @@ bool Platform::setUp()
   OpenSSL_add_all_algorithms();
 #endif // HAVE_OPENSSL
 #ifdef HAVE_LIBGCRYPT
-  if(!gcry_check_version(A2_MIN_GCRYPT_VERSION)) {
+  if(!gcry_check_version("1.2.4")) {
     throw DL_ABORT_EX("gcry_check_version() failed.");
   }
   gcry_control(GCRYCTL_DISABLE_SECMEM, 0);

+ 2 - 2
src/SingleFileAllocationIterator.cc

@@ -45,8 +45,8 @@
 
 namespace aria2 {
 
-#define BUFSIZE (256*1024)
-#define ALIGNMENT 512
+constexpr size_t BUFSIZE = 256 * 1024;
+constexpr size_t ALIGNMENT = 512;
 
 SingleFileAllocationIterator::SingleFileAllocationIterator
 (BinaryStream* stream,