| 2223 | } |
| 2224 | |
| 2225 | int cbm_writer_append_nodes(cbm_db_writer_t *w, const CBMDumpNode *nodes, int count) { |
| 2226 | if (!w) { |
| 2227 | return CBM_NOT_FOUND; |
| 2228 | } |
| 2229 | if (w->err) { |
| 2230 | return w->err; |
| 2231 | } |
| 2232 | for (int i = 0; i < count; i++) { |
| 2233 | int rec_len; |
| 2234 | uint8_t *rec = build_node_record(&nodes[i], &rec_len); |
| 2235 | if (!rec) { |
| 2236 | w->err = ERR_WRITE_FAILED; |
| 2237 | return w->err; |
| 2238 | } |
| 2239 | /* prev_rowid is the previous node's id (0 for the very first), matching |
| 2240 | * the one-shot write_one_table loop — so output is byte-identical. */ |
| 2241 | pb_add_table_cell_with_flush(&w->nodes_pb, nodes[i].id, rec, rec_len, w->last_node_rowid); |
| 2242 | free(rec); |
| 2243 | w->last_node_rowid = nodes[i].id; |
| 2244 | w->node_rows_written++; |
| 2245 | } |
| 2246 | return 0; |
| 2247 | } |
| 2248 | |
| 2249 | int cbm_writer_finalize(cbm_db_writer_t *w, const char *project, const char *root_path, |
| 2250 | const char *indexed_at, CBMDumpNode *nodes, int node_count, |
no test coverage detected