| 2300 | } |
| 2301 | |
| 2302 | int cbm_writer_append_nodes(cbm_db_writer_t *w, const CBMDumpNode *nodes, int count) { |
| 2303 | if (!w) { |
| 2304 | return CBM_NOT_FOUND; |
| 2305 | } |
| 2306 | if (w->err) { |
| 2307 | return w->err; |
| 2308 | } |
| 2309 | for (int i = 0; i < count; i++) { |
| 2310 | int rec_len; |
| 2311 | uint8_t *rec = build_node_record(&nodes[i], &rec_len); |
| 2312 | if (!rec) { |
| 2313 | w->err = ERR_WRITE_FAILED; |
| 2314 | return w->err; |
| 2315 | } |
| 2316 | /* prev_rowid is the previous node's id (0 for the very first), matching |
| 2317 | * the one-shot write_one_table loop — so output is byte-identical. */ |
| 2318 | pb_add_table_cell_with_flush(&w->nodes_pb, nodes[i].id, rec, rec_len, w->last_node_rowid); |
| 2319 | free(rec); |
| 2320 | w->last_node_rowid = nodes[i].id; |
| 2321 | w->node_rows_written++; |
| 2322 | } |
| 2323 | return 0; |
| 2324 | } |
| 2325 | |
| 2326 | int cbm_writer_finalize(cbm_db_writer_t *w, const char *project, const char *root_path, |
| 2327 | const char *indexed_at, CBMDumpNode *nodes, int node_count, |
no test coverage detected