Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
阿啄debugIT
libfastcommon
提交
fdaa6afa
L
libfastcommon
项目概览
阿啄debugIT
/
libfastcommon
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libfastcommon
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
fdaa6afa
编写于
8月 19, 2015
作者:
L
liuwei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
eliminate potential trouble
上级
88215946
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
17 deletion
+32
-17
src/ini_file_reader.c
src/ini_file_reader.c
+30
-16
src/ini_file_reader.h
src/ini_file_reader.h
+2
-1
未找到文件。
src/ini_file_reader.c
浏览文件 @
fdaa6afa
...
...
@@ -30,25 +30,27 @@ static int iniDoLoadFromFile(const char *szFilename, \
static
int
iniDoLoadItemsFromBuffer
(
char
*
content
,
\
IniContext
*
pContext
);
void
iniSetAnnotationCallBack
(
AnnotationMap
*
map
,
int
count
)
int
iniSetAnnotationCallBack
(
AnnotationMap
*
map
,
int
count
)
{
int
bytes
;
AnnotationMap
*
p
;
if
(
count
<=
0
)
{
if
(
count
<=
0
)
{
logWarning
(
"file: "
__FILE__
", line: %d, "
\
"iniSetAnnotationCallBack fail count(%d) is incorrectly."
,
\
__LINE__
,
count
);
return
;
return
EINVAL
;
}
bytes
=
sizeof
(
AnnotationMap
)
*
(
count
+
1
);
g_annotataionMap
=
(
AnnotationMap
*
)
malloc
(
bytes
);
if
(
g_annotataionMap
==
NULL
)
{
if
(
g_annotataionMap
==
NULL
)
{
logError
(
"file: "
__FILE__
", line: %d, "
\
"malloc (%d) fail, errno: %d, error info: %s"
,
\
__LINE__
,
bytes
,
errno
,
STRERROR
(
errno
));
return
;
return
ENOMEM
;
}
memcpy
(
g_annotataionMap
,
map
,
sizeof
(
AnnotationMap
)
*
count
);
...
...
@@ -58,6 +60,29 @@ void iniSetAnnotationCallBack(AnnotationMap *map, int count)
p
->
func_init
=
NULL
;
p
->
func_destroy
=
NULL
;
p
->
func_get
=
NULL
;
return
0
;
}
void
iniDestroyAnnotationCallBack
()
{
AnnotationMap
*
pAnnoMap
;
pAnnoMap
=
g_annotataionMap
;
if
(
pAnnoMap
==
NULL
)
{
return
;
}
while
(
pAnnoMap
->
func_name
)
{
if
(
pAnnoMap
->
func_destroy
)
{
pAnnoMap
->
func_destroy
();
}
pAnnoMap
++
;
}
}
static
int
iniCompareByItemName
(
const
void
*
p1
,
const
void
*
p2
)
...
...
@@ -645,8 +670,6 @@ static int iniFreeHashData(const int index, const HashData *data, void *args)
void
iniFreeContext
(
IniContext
*
pContext
)
{
AnnotationMap
*
pAnnoMap
;
if
(
pContext
==
NULL
)
{
return
;
...
...
@@ -660,15 +683,6 @@ void iniFreeContext(IniContext *pContext)
hash_walk
(
&
pContext
->
sections
,
iniFreeHashData
,
NULL
);
hash_destroy
(
&
pContext
->
sections
);
pAnnoMap
=
g_annotataionMap
;
while
(
pAnnoMap
->
func_name
)
{
if
(
pAnnoMap
->
func_destroy
)
{
pAnnoMap
->
func_destroy
();
}
pAnnoMap
++
;
}
}
...
...
src/ini_file_reader.h
浏览文件 @
fdaa6afa
...
...
@@ -51,7 +51,8 @@ typedef struct
extern
"C"
{
#endif
void
iniSetAnnotationCallBack
(
AnnotationMap
*
map
,
int
count
);
int
iniSetAnnotationCallBack
(
AnnotationMap
*
map
,
int
count
);
void
iniDestroyAnnotationCallBack
();
/** load ini items from file
* parameters:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录