Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xindoo
redis
提交
b1e0bd4b
R
redis
项目概览
xindoo
/
redis
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
b1e0bd4b
编写于
7月 24, 2010
作者:
B
Benjamin Kramer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reduce code duplication
上级
e39c8b50
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
21 addition
and
39 deletion
+21
-39
src/dict.c
src/dict.c
+21
-39
未找到文件。
src/dict.c
浏览文件 @
b1e0bd4b
...
@@ -651,7 +651,7 @@ static unsigned int _dictStringCopyHTHashFunction(const void *key)
...
@@ -651,7 +651,7 @@ static unsigned int _dictStringCopyHTHashFunction(const void *key)
return
dictGenHashFunction
(
key
,
strlen
(
key
));
return
dictGenHashFunction
(
key
,
strlen
(
key
));
}
}
static
void
*
_dictString
CopyHTKey
Dup
(
void
*
privdata
,
const
void
*
key
)
static
void
*
_dictStringDup
(
void
*
privdata
,
const
void
*
key
)
{
{
int
len
=
strlen
(
key
);
int
len
=
strlen
(
key
);
char
*
copy
=
_dictAlloc
(
len
+
1
);
char
*
copy
=
_dictAlloc
(
len
+
1
);
...
@@ -662,17 +662,6 @@ static void *_dictStringCopyHTKeyDup(void *privdata, const void *key)
...
@@ -662,17 +662,6 @@ static void *_dictStringCopyHTKeyDup(void *privdata, const void *key)
return
copy
;
return
copy
;
}
}
static
void
*
_dictStringKeyValCopyHTValDup
(
void
*
privdata
,
const
void
*
val
)
{
int
len
=
strlen
(
val
);
char
*
copy
=
_dictAlloc
(
len
+
1
);
DICT_NOTUSED
(
privdata
);
memcpy
(
copy
,
val
,
len
);
copy
[
len
]
=
'\0'
;
return
copy
;
}
static
int
_dictStringCopyHTKeyCompare
(
void
*
privdata
,
const
void
*
key1
,
static
int
_dictStringCopyHTKeyCompare
(
void
*
privdata
,
const
void
*
key1
,
const
void
*
key2
)
const
void
*
key2
)
{
{
...
@@ -681,47 +670,40 @@ static int _dictStringCopyHTKeyCompare(void *privdata, const void *key1,
...
@@ -681,47 +670,40 @@ static int _dictStringCopyHTKeyCompare(void *privdata, const void *key1,
return
strcmp
(
key1
,
key2
)
==
0
;
return
strcmp
(
key1
,
key2
)
==
0
;
}
}
static
void
_dictStringCopyHTKeyDestructor
(
void
*
privdata
,
void
*
key
)
static
void
_dictStringDestructor
(
void
*
privdata
,
void
*
key
)
{
DICT_NOTUSED
(
privdata
);
_dictFree
((
void
*
)
key
);
/* ATTENTION: const cast */
}
static
void
_dictStringKeyValCopyHTValDestructor
(
void
*
privdata
,
void
*
val
)
{
{
DICT_NOTUSED
(
privdata
);
DICT_NOTUSED
(
privdata
);
_dictFree
(
(
void
*
)
val
);
/* ATTENTION: const cast */
_dictFree
(
key
);
}
}
dictType
dictTypeHeapStringCopyKey
=
{
dictType
dictTypeHeapStringCopyKey
=
{
_dictStringCopyHTHashFunction
,
/* hash function */
_dictStringCopyHTHashFunction
,
/* hash function */
_dictString
CopyHTKeyDup
,
/* key dup */
_dictString
Dup
,
/* key dup */
NULL
,
/* val dup */
NULL
,
/* val dup */
_dictStringCopyHTKeyCompare
,
/* key compare */
_dictStringCopyHTKeyCompare
,
/* key compare */
_dictString
CopyHTKeyDestructor
,
/* key destructor */
_dictString
Destructor
,
/* key destructor */
NULL
/* val destructor */
NULL
/* val destructor */
};
};
/* This is like StringCopy but does not auto-duplicate the key.
/* This is like StringCopy but does not auto-duplicate the key.
* It's used for intepreter's shared strings. */
* It's used for intepreter's shared strings. */
dictType
dictTypeHeapStrings
=
{
dictType
dictTypeHeapStrings
=
{
_dictStringCopyHTHashFunction
,
/* hash function */
_dictStringCopyHTHashFunction
,
/* hash function */
NULL
,
/* key dup */
NULL
,
/* key dup */
NULL
,
/* val dup */
NULL
,
/* val dup */
_dictStringCopyHTKeyCompare
,
/* key compare */
_dictStringCopyHTKeyCompare
,
/* key compare */
_dictString
CopyHTKeyDestructor
,
/* key destructor */
_dictString
Destructor
,
/* key destructor */
NULL
/* val destructor */
NULL
/* val destructor */
};
};
/* This is like StringCopy but also automatically handle dynamic
/* This is like StringCopy but also automatically handle dynamic
* allocated C strings as values. */
* allocated C strings as values. */
dictType
dictTypeHeapStringCopyKeyValue
=
{
dictType
dictTypeHeapStringCopyKeyValue
=
{
_dictStringCopyHTHashFunction
,
/* hash function */
_dictStringCopyHTHashFunction
,
/* hash function */
_dictString
CopyHTKeyDup
,
/* key dup */
_dictString
Dup
,
/* key dup */
_dictString
KeyValCopyHTValDup
,
/* val dup */
_dictString
Dup
,
/* val dup */
_dictStringCopyHTKeyCompare
,
/* key compare */
_dictStringCopyHTKeyCompare
,
/* key compare */
_dictString
CopyHTKeyDestructor
,
/* key destructor */
_dictString
Destructor
,
/* key destructor */
_dictString
KeyValCopyHTValDestructor
,
/* val destructor */
_dictString
Destructor
,
/* val destructor */
};
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录