MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / SIPath_ToString

Function SIPath_ToString

src/datatypes/path/sipath.c:115–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113}
114
115void SIPath_ToString(SIValue p, char **buf, size_t *bufferLen, size_t *bytesWritten) {
116 // 64 is defiend arbitrarily.
117 if(*bufferLen - *bytesWritten < 64) {
118 *bufferLen += 64;
119 *buf = rm_realloc(*buf, sizeof(char) * *bufferLen);
120 }
121 // open path with "["
122 *bytesWritten += snprintf(*buf + *bytesWritten, *bufferLen, "[");
123
124 size_t nodeCount = SIPath_NodeCount(p);
125 for(size_t i = 0; i < nodeCount - 1; i ++) {
126 // write the next value
127 SIValue node = SIPath_GetNode(p, i);
128 SIValue_ToString(node, buf, bufferLen, bytesWritten);
129 * bytesWritten += snprintf(*buf + *bytesWritten, *bufferLen, ", ");
130 SIValue edge = SIPath_GetRelationship(p, i);
131 SIValue_ToString(edge, buf, bufferLen, bytesWritten);
132 * bytesWritten += snprintf(*buf + *bytesWritten, *bufferLen, ", ");
133 }
134 // Handle last node.
135 if(nodeCount > 0) {
136 SIValue node = SIPath_GetNode(p, nodeCount - 1);
137 SIValue_ToString(node, buf, bufferLen, bytesWritten);
138 }
139
140 if(*bufferLen - *bytesWritten < 2) {
141 *bufferLen += 2;
142 *buf = rm_realloc(*buf, sizeof(char) * *bufferLen);
143 }
144 // close array with "]"
145 *bytesWritten += snprintf(*buf + *bytesWritten, *bufferLen, "]");
146}
147
148int SIPath_Compare(SIValue p1, SIValue p2) {
149

Callers 1

SIValue_ToStringFunction · 0.85

Calls 5

rm_reallocFunction · 0.85
SIPath_NodeCountFunction · 0.85
SIPath_GetNodeFunction · 0.85
SIValue_ToStringFunction · 0.85
SIPath_GetRelationshipFunction · 0.85

Tested by

no test coverage detected