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

Function yaml_build_lines

src/cli/config_yaml_edit.c:1125–1152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1123}
1124
1125static int yaml_build_lines(yaml_doc_t *doc) {
1126 size_t count = yaml_count_lines(doc);
1127 if (count == 0U) {
1128 yaml_detect_eol(doc);
1129 return 0;
1130 }
1131 if (count > SIZE_MAX / sizeof(yaml_line_t)) {
1132 return YAML_ERROR;
1133 }
1134 yaml_line_t *lines = (yaml_line_t *)calloc(count, sizeof(*lines));
1135 if (!lines) {
1136 return YAML_ERROR;
1137 }
1138
1139 size_t line_index = 0U;
1140 size_t start = 0U;
1141 while (start < doc->len && line_index < count) {
1142 start = yaml_parse_line(doc, start, &lines[line_index++]);
1143 }
1144 if (start != doc->len || line_index != count) {
1145 free(lines);
1146 return YAML_ERROR;
1147 }
1148 doc->lines = lines;
1149 doc->line_count = count;
1150 yaml_detect_eol(doc);
1151 return 0;
1152}
1153
1154static void yaml_doc_free(yaml_doc_t *doc) {
1155 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