refactor(argparse): 将null替换为nullptr以提高C++兼容性
- 在argparse库中将所有null指针常量替换为nullptr - 更新头文件和源文件中的指针初始化和比较操作 - 修改测试文件中的相关断言检查 - 更新AST定义文件中的注释说明
This commit is contained in:
@@ -10,9 +10,9 @@
|
||||
#ifndef __KLLIST_H__
|
||||
#define __KLLIST_H__
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL (0)
|
||||
#define __NULL_KLIST_DEFINED__
|
||||
#ifndef nullptr
|
||||
#define nullptr (0)
|
||||
#define __nullptr_KLIST_DEFINED__
|
||||
#endif
|
||||
|
||||
#ifndef container_of
|
||||
@@ -88,8 +88,8 @@ static inline void __list_del(struct list_head *prev, struct list_head *next) {
|
||||
|
||||
static inline void list_del(struct list_head *entry) {
|
||||
__list_del(entry->prev, entry->next);
|
||||
entry->next = NULL;
|
||||
entry->prev = NULL;
|
||||
entry->next = nullptr;
|
||||
entry->prev = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,8 +159,9 @@ typedef int (*list_cmp_func_t)(void *, const struct list_head *,
|
||||
static void list_sort(void *priv, struct list_head *head, list_cmp_func_t cmp);
|
||||
#endif
|
||||
|
||||
#if defined(__NULL_KLIST_DEFINED__) && !defined(__NULL_KLIST_DEFINED_NOMOVE__)
|
||||
#undef NULL
|
||||
#if defined(__nullptr_KLIST_DEFINED__) && \
|
||||
!defined(__nullptr_KLIST_DEFINED_NOMOVE__)
|
||||
#undef nullptr
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -76,7 +76,7 @@ void scc_hashtable_init(scc_hashtable_t *ht,
|
||||
* @param ht 哈希表实例指针
|
||||
* @param key 键指针
|
||||
* @param value 值指针
|
||||
* @return 被替换的旧值指针(无替换返回NULL)
|
||||
* @return 被替换的旧值指针(无替换返回nullptr)
|
||||
*/
|
||||
void *scc_hashtable_set(scc_hashtable_t *ht, const void *key, void *value);
|
||||
|
||||
@@ -84,7 +84,7 @@ void *scc_hashtable_set(scc_hashtable_t *ht, const void *key, void *value);
|
||||
* @brief 查找键对应值
|
||||
* @param ht 哈希表实例指针
|
||||
* @param key 查找键指针
|
||||
* @return 找到返回值指针,未找到返回NULL
|
||||
* @return 找到返回值指针,未找到返回nullptr
|
||||
*/
|
||||
void *scc_hashtable_get(scc_hashtable_t *ht, const void *key);
|
||||
|
||||
@@ -92,7 +92,7 @@ void *scc_hashtable_get(scc_hashtable_t *ht, const void *key);
|
||||
* @brief 删除键值对
|
||||
* @param ht 哈希表实例指针
|
||||
* @param key 要删除的键指针
|
||||
* @return 被删除的值指针(不存在返回NULL)
|
||||
* @return 被删除的值指针(不存在返回nullptr)
|
||||
*
|
||||
* @note 实际采用墓碑标记方式删除
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user