| 146 | } |
| 147 | |
| 148 | int SIPath_Compare(SIValue p1, SIValue p2) { |
| 149 | |
| 150 | size_t p1NodeCount = SIPath_NodeCount(p1); |
| 151 | size_t p2NodeCount = SIPath_NodeCount(p2); |
| 152 | // Get minimal length |
| 153 | size_t nodeCount = p1NodeCount <= p2NodeCount ? p1NodeCount : p2NodeCount; |
| 154 | int res = 0; |
| 155 | for(size_t i = 0; i < nodeCount - 1 ; i++) { |
| 156 | SIValue p1node = SIPath_GetNode(p1, i); |
| 157 | SIValue p2node = SIPath_GetNode(p2, i); |
| 158 | res = SIValue_Compare(p1node, p2node, NULL); |
| 159 | if(res) return res; |
| 160 | SIValue p1edge = SIPath_GetRelationship(p1, i); |
| 161 | SIValue p2edge = SIPath_GetRelationship(p2, i); |
| 162 | res = SIValue_Compare(p1edge, p2edge, NULL); |
| 163 | if(res) return res; |
| 164 | } |
| 165 | // Handle last node. |
| 166 | if(nodeCount > 0) { |
| 167 | SIValue p1node = SIPath_GetNode(p1, nodeCount - 1); |
| 168 | SIValue p2node = SIPath_GetNode(p2, nodeCount - 1); |
| 169 | res = SIValue_Compare(p1node, p2node, NULL); |
| 170 | if(res) return res; |
| 171 | } |
| 172 | return p1NodeCount - p2NodeCount; |
| 173 | } |
| 174 | |
| 175 | void SIPath_Free(SIValue p) { |
| 176 | if(p.allocation == M_SELF) { |
no test coverage detected