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

Function SIArray_ToString

src/datatypes/array.c:140–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138}
139
140void SIArray_ToString(SIValue list, char **buf, size_t *bufferLen, size_t *bytesWritten) {
141 if(*bufferLen - *bytesWritten < 64) {
142 *bufferLen += 64;
143 *buf = rm_realloc(*buf, sizeof(char) * *bufferLen);
144 }
145 // open array with "["
146 *bytesWritten += snprintf(*buf + *bytesWritten, *bufferLen, "[");
147 uint arrayLen = SIArray_Length(list);
148 for(uint i = 0; i < arrayLen; i ++) {
149 // write the next value
150 SIValue_ToString(list.array[i], buf, bufferLen, bytesWritten);
151 // if it is not the last element, add ", "
152 if(i != arrayLen - 1) {
153 if(*bufferLen - *bytesWritten < 64) {
154 *bufferLen += 64;
155 *buf = rm_realloc(*buf, sizeof(char) * *bufferLen);
156 }
157 *bytesWritten += snprintf(*buf + *bytesWritten, *bufferLen, ", ");
158 }
159 }
160 if(*bufferLen - *bytesWritten < 2) {
161 *bufferLen += 2;
162 *buf = rm_realloc(*buf, sizeof(char) * *bufferLen);
163 }
164 // close array with "]"
165 *bytesWritten += snprintf(*buf + *bytesWritten, *bufferLen, "]");
166}
167
168// this method referenced by Java ArrayList.hashCode() method, which takes
169// into account the hasing of nested values

Callers 1

SIValue_ToStringFunction · 0.85

Calls 3

rm_reallocFunction · 0.85
SIArray_LengthFunction · 0.85
SIValue_ToStringFunction · 0.85

Tested by

no test coverage detected