in src/h3lib/lib/h3Index.c [220:243]
void H3_EXPORT(h3ToChildren)(H3Index h, int childRes, H3Index* children) {
int parentRes = H3_GET_RESOLUTION(h);
if (!_isValidChildRes(parentRes, childRes)) {
return;
} else if (parentRes == childRes) {
*children = h;
return;
}
int bufferSize = H3_EXPORT(maxH3ToChildrenSize)(h, childRes);
int bufferChildStep = (bufferSize / 7);
int isAPentagon = H3_EXPORT(h3IsPentagon)(h);
for (int i = 0; i < 7; i++) {
if (isAPentagon && i == K_AXES_DIGIT) {
H3Index* nextChild = children + bufferChildStep;
while (children < nextChild) {
*children = H3_NULL;
children++;
}
} else {
H3_EXPORT(h3ToChildren)(makeDirectChild(h, i), childRes, children);
children += bufferChildStep;
}
}
}