Fill out[0..max) with the next start nodes. Fewer than max only once the * scan is exhausted or has failed. */
| 6090 | /* Fill out[0..max) with the next start nodes. Fewer than max only once the |
| 6091 | * scan is exhausted or has failed. */ |
| 6092 | static int start_source_next(start_source_t *src, cbm_node_t *out, int max) { |
| 6093 | const cbm_node_pattern_t *node = src->node; |
| 6094 | int got = 0; |
| 6095 | while (got < max && !src->done) { |
| 6096 | if (!src->scan) { |
| 6097 | if (!src->labels || !start_source_next_label(src)) { |
| 6098 | src->done = true; |
| 6099 | } |
| 6100 | continue; |
| 6101 | } |
| 6102 | int n = 0; |
| 6103 | if (cbm_store_node_scan_next(src->scan, out + got, max - got, &n) != CBM_STORE_OK) { |
| 6104 | start_source_fail(src, cbm_store_error(src->store)); |
| 6105 | break; |
| 6106 | } |
| 6107 | if (n == 0) { |
| 6108 | cbm_store_node_scan_close(src->scan); |
| 6109 | src->scan = NULL; |
| 6110 | src->done = !src->labels; |
| 6111 | continue; |
| 6112 | } |
| 6113 | /* Apply inline property filters — free rejected nodes' strings */ |
| 6114 | int kept = got; |
| 6115 | for (int i = got; i < got + n; i++) { |
| 6116 | if (node->prop_count == 0 || |
| 6117 | check_inline_props(&out[i], node->props, node->prop_count, src->store)) { |
| 6118 | if (kept != i) { |
| 6119 | out[kept] = out[i]; |
| 6120 | } |
| 6121 | kept++; |
| 6122 | } else { |
| 6123 | node_fields_free(&out[i]); |
| 6124 | } |
| 6125 | } |
| 6126 | got = kept; |
| 6127 | } |
| 6128 | return got; |
| 6129 | } |
| 6130 | |
| 6131 | static void start_source_close(start_source_t *src) { |
| 6132 | cbm_store_node_scan_close(src->scan); |
no test coverage detected