Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Ip2region
提交
16aba8c9
I
Ip2region
项目概览
int
/
Ip2region
上一次同步 11 个月
通知
19
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
Ip2region
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
16aba8c9
编写于
6月 29, 2022
作者:
L
Lion
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
safe the type convertion
上级
246165b3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
5 addition
and
13 deletion
+5
-13
binding/c/xdb_searcher.c
binding/c/xdb_searcher.c
+4
-4
binding/c/xdb_searcher.h
binding/c/xdb_searcher.h
+1
-9
未找到文件。
binding/c/xdb_searcher.c
浏览文件 @
16aba8c9
...
...
@@ -74,8 +74,8 @@ XDB_PUBLIC(int) xdb_search(xdb_searcher_t *xdb, unsigned int ip, char *region_bu
xdb
->
io_count
=
0
;
// locate the segment index block based on the vector index
il0
=
(
ip
>>
24
)
&
0xFF
;
il1
=
(
ip
>>
16
)
&
0xFF
;
il0
=
(
(
int
)
(
ip
>>
24
)
)
&
0xFF
;
il1
=
(
(
int
)
(
ip
>>
16
)
)
&
0xFF
;
idx
=
il0
*
xdb_vector_index_cols
*
xdb_vector_index_size
+
il1
*
xdb_vector_index_size
;
if
(
xdb
->
vector_index
!=
NULL
)
{
s_ptr
=
get_unsigned_int
(
xdb
->
vector_index
,
idx
);
...
...
@@ -96,7 +96,7 @@ XDB_PUBLIC(int) xdb_search(xdb_searcher_t *xdb, unsigned int ip, char *region_bu
// printf("s_ptr=%u, e_ptr=%u\n", s_ptr, e_ptr);
// binary search to get the final region info
data_len
=
0
,
data_ptr
=
0
;
l
=
0
,
h
=
(
e_ptr
-
s_ptr
)
/
xdb_segment_index_size
;
l
=
0
,
h
=
(
(
int
)
(
e_ptr
-
s_ptr
)
)
/
xdb_segment_index_size
;
while
(
l
<=
h
)
{
m
=
(
l
+
h
)
>>
1
;
p
=
s_ptr
+
m
*
xdb_segment_index_size
;
...
...
@@ -284,7 +284,7 @@ XDB_PUBLIC(unsigned int) get_unsigned_int(const char *buffer, int offset) {
}
// get unsigned short (2bytes) from a specified buffer start from the specified offset
XDB_PUBLIC
(
unsigned
int
)
get_unsigned_short
(
const
char
*
buffer
,
int
offset
)
{
XDB_PUBLIC
(
int
)
get_unsigned_short
(
const
char
*
buffer
,
int
offset
)
{
return
(
((
buffer
[
offset
])
&
0x000000FF
)
|
((
buffer
[
offset
+
1
]
<<
8
)
&
0x0000FF00
)
...
...
binding/c/xdb_searcher.h
浏览文件 @
16aba8c9
...
...
@@ -23,14 +23,6 @@
# define XDB_LINUX
#endif
// memory allocation error
#define XDB_ALLOCATE_ERROR(func, bytes) \
do { \
printf("<XDB>: Allocate Error In Function <%s> For %lu Bytes.\n", func, (unsigned long int) bytes); \
return NULL; \
} while (0);
#define xdb_calloc( _blocks, _bytes ) calloc( _blocks, _bytes )
#define xdb_malloc( _bytes ) malloc( _bytes )
#define xdb_free( _ptr ) free( _ptr )
...
...
@@ -112,7 +104,7 @@ XDB_PUBLIC(char *) xdb_load_content_from_file(char *);
XDB_PUBLIC
(
unsigned
int
)
get_unsigned_int
(
const
char
*
,
int
);
// get unsigned short (2bytes) from a specified buffer start from the specified offset with little-endian
XDB_PUBLIC
(
unsigned
int
)
get_unsigned_short
(
const
char
*
,
int
);
XDB_PUBLIC
(
int
)
get_unsigned_short
(
const
char
*
,
int
);
// check the specified string ip and convert it to an unsigned int
XDB_PUBLIC
(
int
)
check_ip
(
const
char
*
,
unsigned
int
*
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录