From b3c89b2316672633e5f5c4bba18f799106ee2873 Mon Sep 17 00:00:00 2001 From: yuqing Date: Thu, 6 Jul 2017 10:47:03 +0800 Subject: [PATCH] add IS_HEX_CHAR macro define --- src/common_define.h | 2 ++ src/hash.c | 4 ++-- src/hash.h | 4 ++-- src/shared_func.c | 5 ----- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/common_define.h b/src/common_define.h index b6e59ae..51cd585 100644 --- a/src/common_define.h +++ b/src/common_define.h @@ -116,6 +116,8 @@ extern int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int kind); #endif #define IS_UPPER_HEX(ch) ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F')) +#define IS_HEX_CHAR(ch) (IS_UPPER_HEX(ch) || (ch >= 'a' && ch <= 'f')) + #define STRERROR(no) (strerror(no) != NULL ? strerror(no) : "Unkown error") #if defined(OS_LINUX) diff --git a/src/hash.c b/src/hash.c index ec9d50f..a1e3c7f 100644 --- a/src/hash.c +++ b/src/hash.c @@ -1379,14 +1379,14 @@ static unsigned int crc_table[256] = { crc = crc_table[(crc ^ *pKey) & 0xFF] ^ (crc >> 8); \ } \ -int CRC32(void *key, const int key_len) +int CRC32(const void *key, const int key_len) { CRC32_BODY(CRC32_XINIT) return crc ^ CRC32_XOROT; } -int CRC32_ex(void *key, const int key_len, \ +int CRC32_ex(const void *key, const int key_len, \ const int init_value) { CRC32_BODY(init_value) diff --git a/src/hash.h b/src/hash.h index 7e31c38..6be86cd 100644 --- a/src/hash.h +++ b/src/hash.h @@ -350,8 +350,8 @@ int simple_hash(const void* key, const int key_len); int simple_hash_ex(const void* key, const int key_len, \ const int init_value); -int CRC32(void *key, const int key_len); -int CRC32_ex(void *key, const int key_len, \ +int CRC32(const void *key, const int key_len); +int CRC32_ex(const void *key, const int key_len, \ const int init_value); #define CRC32_FINAL(crc) (crc ^ CRC32_XOROT) diff --git a/src/shared_func.c b/src/shared_func.c index 44708a6..dd7b302 100644 --- a/src/shared_func.c +++ b/src/shared_func.c @@ -2113,11 +2113,6 @@ char *urldecode(const char *src, const int src_len, char *dest, int *dest_len) char *urldecode_ex(const char *src, const int src_len, char *dest, int *dest_len) { -#define IS_HEX_CHAR(ch) \ - ((ch >= '0' && ch <= '9') || \ - (ch >= 'a' && ch <= 'f') || \ - (ch >= 'A' && ch <= 'F')) - #define HEX_VALUE(ch, value) \ if (ch >= '0' && ch <= '9') \ { \