JNIEXPORT jlong JNICALL Java_com_uber_h3core_NativeMethods_constructCell()

in src/main/c/h3-java/src/jniapi.c [226:246]


JNIEXPORT jlong JNICALL Java_com_uber_h3core_NativeMethods_constructCell(
    JNIEnv *env, jobject thiz, jint res, jint baseCell, jintArray digits) {
    H3Index result = 0;
    jint *digitsElements = (**env).GetIntArrayElements(env, digits, 0);

    if (digitsElements != NULL) {
        // if sz is too small, bad things will happen
        // note: We assume int can at least contain `jint` on the current
        // platform. This may not be true if sizeof(int) < 32, but we don't
        // support any platforms where this would be the case.
        H3Error err = constructCell(res, baseCell, digitsElements, &result);

        (**env).ReleaseIntArrayElements(env, digits, digitsElements, 0);
        if (err) {
            ThrowH3Exception(env, err);
        }
    } else {
        ThrowOutOfMemoryError(env);
    }
    return result;
}