function destroyGeoPolygon()

in lib/h3core.js [369:388]


function destroyGeoPolygon(geoPolygon) {
    // Byte positions within the struct
    const geoLoopOffset = 0;
    const numHolesOffset = geoLoopOffset + SZ_GEOLOOP;
    const holesOffset = numHolesOffset + SZ_INT;
    // Offset of the geoLoop vertex array pointer within the GeoLoop struct
    const geoLoopArrayOffset = SZ_INT;
    // Free the outer vertex array
    C._free(C.getValue(geoPolygon + geoLoopOffset + geoLoopArrayOffset, 'i8*'));
    // Free the vertex array for the holes, if any
    const numHoles = C.getValue(geoPolygon + numHolesOffset, 'i32');
    if (numHoles > 0) {
        const holes = C.getValue(geoPolygon + holesOffset, 'i32');
        for (let i = 0; i < numHoles; i++) {
            C._free(C.getValue(holes + SZ_GEOLOOP * i + geoLoopArrayOffset, 'i8*'));
        }
        C._free(holes);
    }
    C._free(geoPolygon);
}