MCPcopy Create free account
hub / github.com/acl-dev/acl / load_objs

Function load_objs

lib_acl_cpp/samples/diff/main.cpp:41–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41static int load_objs(acl::diff_manager& manager, const char* filepath,
42 std::vector<acl::diff_object*>& new_objs)
43{
44 acl::ifstream in;
45
46 // 以只读方式打开数据文件
47 if (in.open_read(filepath) == false)
48 {
49 printf("open %s error %s\r\n", filepath, acl::last_serror());
50 return -1;
51 }
52
53 // 从比较器中获得内存池对象,以便于下面分配内存
54 acl::dbuf_guard& dbuf = manager.get_dbuf();
55 int linenum = 0;
56 acl::string line;
57
58 int nobjs = 0;
59
60 while (!in.eof())
61 {
62 line.clear();
63
64 // 从文件中读取一行数据
65 if (in.gets(line) == false)
66 break;
67
68 linenum++;
69
70 // 分析该行数据,提取 key 和 value 值
71 char* key = line.c_str();
72 char* val = strrchr(key, '|');
73
74 // 检查数据的有效性
75 if (val == NULL || val == key || *(val + 1) == 0)
76 {
77 printf("invalid line: %s in %s, linenum: %d\r\n",
78 key, filepath, linenum);
79 continue;
80 }
81 *val++ = 0;
82
83 // 创建 diff 对象,并置入对象集合中
84 mail_object* obj = new (dbuf.dbuf_alloc(sizeof(mail_object)))
85 mail_object(manager, key, val);
86 new_objs.push_back(obj);
87 nobjs++;
88 }
89
90 return nobjs;
91}
92
93static bool check_diff(const char* new_file, const char* old_file,
94 const DIFF_RES* res = NULL)

Callers 1

check_diffFunction · 0.85

Calls 9

get_dbufMethod · 0.80
getsMethod · 0.80
dbuf_allocMethod · 0.80
last_serrorFunction · 0.50
open_readMethod · 0.45
eofMethod · 0.45
clearMethod · 0.45
c_strMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…