refactor(argparse): 将null替换为nullptr以提高C++兼容性
- 在argparse库中将所有null指针常量替换为nullptr - 更新头文件和源文件中的指针初始化和比较操作 - 修改测试文件中的相关断言检查 - 更新AST定义文件中的注释说明
This commit is contained in:
@@ -22,14 +22,14 @@ static void load_from_def(pe_idata_lib_ctx_t *ctx, const char *file_path,
|
||||
scc_str_append_cstr(&fpath, ".def", 4);
|
||||
const char *fname = scc_str_as_cstr(&fpath);
|
||||
scc_file_t fp = scc_fopen(fname, SCC_FILE_READ);
|
||||
if (fp == null) {
|
||||
if (fp == nullptr) {
|
||||
LOG_ERROR("load_from_def file read error: %s", fname);
|
||||
return;
|
||||
}
|
||||
|
||||
usize fsize = scc_fsize(fp);
|
||||
char *buffer = scc_malloc(fsize);
|
||||
Assert(buffer != null);
|
||||
Assert(buffer != nullptr);
|
||||
|
||||
usize read_size = scc_fread(fp, buffer, fsize);
|
||||
Assert(read_size == fsize);
|
||||
@@ -71,11 +71,11 @@ static void pe_idata_lib_init(pe_idata_lib_ctx_t *ctx, const char *find_path) {
|
||||
|
||||
static cbool pe_idata_get(pe_idata_lib_ctx_t *ctx, const char *name) {
|
||||
const char *lib_name = scc_hashtable_get(&ctx->str2libsym, name);
|
||||
if (lib_name == null) {
|
||||
if (lib_name == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
scc_pe_idata_lib_t *lib = null;
|
||||
scc_pe_idata_lib_t *lib = nullptr;
|
||||
scc_vec_foreach(ctx->idata_libs, i) {
|
||||
scc_pe_idata_lib_t *idata_lib = &scc_vec_at(ctx->idata_libs, i);
|
||||
if (scc_strcmp(lib_name, idata_lib->name) == 0) {
|
||||
@@ -83,7 +83,7 @@ static cbool pe_idata_get(pe_idata_lib_ctx_t *ctx, const char *name) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (lib == null) {
|
||||
if (lib == nullptr) {
|
||||
scc_pe_idata_lib_t new_lib;
|
||||
new_lib.name = lib_name;
|
||||
scc_vec_init(new_lib.symbol_names);
|
||||
@@ -104,8 +104,8 @@ void sccf2pe(scc_pe_builder_t *builder, const sccf_t *sccf) {
|
||||
sccf_sym_vec_t symtab;
|
||||
scc_vec_init(symtab);
|
||||
|
||||
sccf_sect_data_t *code_data = null;
|
||||
sccf_sect_data_t *data_data = null;
|
||||
sccf_sect_data_t *code_data = nullptr;
|
||||
sccf_sect_data_t *data_data = nullptr;
|
||||
int num_of_section = 1;
|
||||
scc_vec_foreach(sccf->sect_headers, i) {
|
||||
sccf_sect_header_t *sect_header = &scc_vec_at(sccf->sect_headers, i);
|
||||
@@ -221,18 +221,18 @@ void sccf2pe(scc_pe_builder_t *builder, const sccf_t *sccf) {
|
||||
TODO();
|
||||
}
|
||||
rva -= code_range.virual_address + reloc->offset + reloc->addend;
|
||||
Assert(code_data != null);
|
||||
Assert(code_data != nullptr);
|
||||
// FIXME 需要确保宿主机与目标机器大小端一致
|
||||
*(u32 *)(scc_vec_unsafe_get_data(*code_data) + reloc->offset) = rva;
|
||||
}
|
||||
|
||||
scc_pe_write_header(builder, &config);
|
||||
if (code_data != null) {
|
||||
if (code_data != nullptr) {
|
||||
scc_pe_write_section(builder, &code_range,
|
||||
(u8 *)scc_vec_unsafe_get_data(*code_data),
|
||||
scc_vec_size(*code_data));
|
||||
}
|
||||
if (data_data != null) {
|
||||
if (data_data != nullptr) {
|
||||
scc_pe_write_section(builder, &data_range,
|
||||
(u8 *)scc_vec_unsafe_get_data(*data_data),
|
||||
scc_vec_size(*data_data));
|
||||
|
||||
Reference in New Issue
Block a user