MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / yaml_build_lines

Function yaml_build_lines

src/cli/config_yaml_edit.c:1074–1101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1072}
1073
1074static int yaml_build_lines(yaml_doc_t *doc) {
1075 size_t count = yaml_count_lines(doc);
1076 if (count == 0U) {
1077 yaml_detect_eol(doc);
1078 return 0;
1079 }
1080 if (count > SIZE_MAX / sizeof(yaml_line_t)) {
1081 return YAML_ERROR;
1082 }
1083 yaml_line_t *lines = (yaml_line_t *)calloc(count, sizeof(*lines));
1084 if (!lines) {
1085 return YAML_ERROR;
1086 }
1087
1088 size_t line_index = 0U;
1089 size_t start = 0U;
1090 while (start < doc->len && line_index < count) {
1091 start = yaml_parse_line(doc, start, &lines[line_index++]);
1092 }
1093 if (start != doc->len || line_index != count) {
1094 free(lines);
1095 return YAML_ERROR;
1096 }
1097 doc->lines = lines;
1098 doc->line_count = count;
1099 yaml_detect_eol(doc);
1100 return 0;
1101}
1102
1103static void yaml_doc_free(yaml_doc_t *doc) {
1104 free(doc->lines);

Callers 1

yaml_doc_initFunction · 0.85

Calls 3

yaml_count_linesFunction · 0.85
yaml_detect_eolFunction · 0.85
yaml_parse_lineFunction · 0.85

Tested by

no test coverage detected