| 78 | }; |
| 79 | |
| 80 | static int cmp_node_ptr_canonical(const void *pa, const void *pb) { |
| 81 | const cbm_gbuf_node_t *a = *(const cbm_gbuf_node_t *const *)pa; |
| 82 | const cbm_gbuf_node_t *b = *(const cbm_gbuf_node_t *const *)pb; |
| 83 | const char *qa = a->qualified_name ? a->qualified_name : ""; |
| 84 | const char *qb = b->qualified_name ? b->qualified_name : ""; |
| 85 | int r = strcmp(qa, qb); |
| 86 | if (r != 0) { |
| 87 | return r; |
| 88 | } |
| 89 | const char *fa = a->file_path ? a->file_path : ""; |
| 90 | const char *fb = b->file_path ? b->file_path : ""; |
| 91 | r = strcmp(fa, fb); |
| 92 | if (r != 0) { |
| 93 | return r; |
| 94 | } |
| 95 | if (a->start_line != b->start_line) { |
| 96 | return a->start_line < b->start_line ? CANON_CMP_LESS : CANON_CMP_GREATER; |
| 97 | } |
| 98 | const char *na = a->name ? a->name : ""; |
| 99 | const char *nb = b->name ? b->name : ""; |
| 100 | return strcmp(na, nb); |
| 101 | } |
| 102 | |
| 103 | /* Heap copy of `nodes` sorted by cmp_node_ptr_canonical. Returns NULL (and |
| 104 | * leaves the caller on the unsorted borrowed array) only on allocation |
nothing calls this directly
no outgoing calls
no test coverage detected