Skip to content

Commit

Permalink
accept size parameter for polygonToCellsExperimental
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacbrodsky committed Nov 28, 2024
1 parent e45b999 commit c8f1f72
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 91 deletions.
18 changes: 9 additions & 9 deletions src/apps/benchmarks/benchmarkPolygonToCellsExperimental.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ BENCHMARK(polygonToCellsSF_Center, 500, {
(&sfGeoPolygon, 9, CONTAINMENT_CENTER, &numHexagons);
hexagons = calloc(numHexagons, sizeof(H3Index));
H3_EXPORT(polygonToCellsExperimental)
(&sfGeoPolygon, 9, CONTAINMENT_CENTER, hexagons);
(&sfGeoPolygon, 9, CONTAINMENT_CENTER, numHexagons, hexagons);
free(hexagons);
});

Expand All @@ -137,7 +137,7 @@ BENCHMARK(polygonToCellsSF_Full, 500, {
(&sfGeoPolygon, 9, CONTAINMENT_FULL, &numHexagons);
hexagons = calloc(numHexagons, sizeof(H3Index));
H3_EXPORT(polygonToCellsExperimental)
(&sfGeoPolygon, 9, CONTAINMENT_FULL, hexagons);
(&sfGeoPolygon, 9, CONTAINMENT_FULL, numHexagons, hexagons);
free(hexagons);
});

Expand All @@ -146,7 +146,7 @@ BENCHMARK(polygonToCellsSF_Overlapping, 500, {
(&sfGeoPolygon, 9, CONTAINMENT_OVERLAPPING, &numHexagons);
hexagons = calloc(numHexagons, sizeof(H3Index));
H3_EXPORT(polygonToCellsExperimental)
(&sfGeoPolygon, 9, CONTAINMENT_OVERLAPPING, hexagons);
(&sfGeoPolygon, 9, CONTAINMENT_OVERLAPPING, numHexagons, hexagons);
free(hexagons);
});

Expand All @@ -155,7 +155,7 @@ BENCHMARK(polygonToCellsAlameda_Center, 500, {
(&alamedaGeoPolygon, 9, CONTAINMENT_CENTER, &numHexagons);
hexagons = calloc(numHexagons, sizeof(H3Index));
H3_EXPORT(polygonToCellsExperimental)
(&alamedaGeoPolygon, 9, CONTAINMENT_CENTER, hexagons);
(&alamedaGeoPolygon, 9, CONTAINMENT_CENTER, numHexagons, hexagons);
free(hexagons);
});

Expand All @@ -164,7 +164,7 @@ BENCHMARK(polygonToCellsAlameda_Full, 500, {
(&alamedaGeoPolygon, 9, CONTAINMENT_FULL, &numHexagons);
hexagons = calloc(numHexagons, sizeof(H3Index));
H3_EXPORT(polygonToCellsExperimental)
(&alamedaGeoPolygon, 9, CONTAINMENT_FULL, hexagons);
(&alamedaGeoPolygon, 9, CONTAINMENT_FULL, numHexagons, hexagons);
free(hexagons);
});

Expand All @@ -173,7 +173,7 @@ BENCHMARK(polygonToCellsAlameda_Overlapping, 500, {
(&alamedaGeoPolygon, 9, CONTAINMENT_OVERLAPPING, &numHexagons);
hexagons = calloc(numHexagons, sizeof(H3Index));
H3_EXPORT(polygonToCellsExperimental)
(&alamedaGeoPolygon, 9, CONTAINMENT_OVERLAPPING, hexagons);
(&alamedaGeoPolygon, 9, CONTAINMENT_OVERLAPPING, numHexagons, hexagons);
free(hexagons);
});

Expand All @@ -182,7 +182,7 @@ BENCHMARK(polygonToCellsSouthernExpansion_Center, 10, {
(&southernGeoPolygon, 9, CONTAINMENT_CENTER, &numHexagons);
hexagons = calloc(numHexagons, sizeof(H3Index));
H3_EXPORT(polygonToCellsExperimental)
(&southernGeoPolygon, 9, CONTAINMENT_CENTER, hexagons);
(&southernGeoPolygon, 9, CONTAINMENT_CENTER, numHexagons, hexagons);
free(hexagons);
});

Expand All @@ -191,7 +191,7 @@ BENCHMARK(polygonToCellsSouthernExpansion_Full, 10, {
(&southernGeoPolygon, 9, CONTAINMENT_FULL, &numHexagons);
hexagons = calloc(numHexagons, sizeof(H3Index));
H3_EXPORT(polygonToCellsExperimental)
(&southernGeoPolygon, 9, CONTAINMENT_FULL, hexagons);
(&southernGeoPolygon, 9, CONTAINMENT_FULL, numHexagons, hexagons);
free(hexagons);
});

Expand All @@ -200,7 +200,7 @@ BENCHMARK(polygonToCellsSouthernExpansion_Overlapping, 10, {
(&southernGeoPolygon, 9, CONTAINMENT_OVERLAPPING, &numHexagons);
hexagons = calloc(numHexagons, sizeof(H3Index));
H3_EXPORT(polygonToCellsExperimental)
(&southernGeoPolygon, 9, CONTAINMENT_OVERLAPPING, hexagons);
(&southernGeoPolygon, 9, CONTAINMENT_OVERLAPPING, numHexagons, hexagons);
free(hexagons);
});

Expand Down
2 changes: 1 addition & 1 deletion src/apps/fuzzers/fuzzerPolygonToCellsExperimental.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void run(GeoPolygon *geoPolygon, uint32_t flags, int res) {
flags, &sz);
if (!err && sz < MAX_SZ) {
H3Index *out = calloc(sz, sizeof(H3Index));
H3_EXPORT(polygonToCellsExperimental)(geoPolygon, res, flags, out);
H3_EXPORT(polygonToCellsExperimental)(geoPolygon, res, flags, sz, out);
free(out);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/apps/fuzzers/fuzzerPolygonToCellsExperimentalNoHoles.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void run(GeoPolygon *geoPolygon, uint32_t flags, int res) {
flags, &sz);
if (!err && sz < MAX_SZ) {
H3Index *out = calloc(sz, sizeof(H3Index));
H3_EXPORT(polygonToCellsExperimental)(geoPolygon, res, flags, out);
H3_EXPORT(polygonToCellsExperimental)(geoPolygon, res, flags, sz, out);
free(out);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/apps/testapps/testH3Memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,15 @@ SUITE(h3Memory) {
resetMemoryCounters(0);
failAlloc = true;
H3Error err = H3_EXPORT(polygonToCellsExperimental)(
&sfGeoPolygon, 9, CONTAINMENT_CENTER, hexagons);
&sfGeoPolygon, 9, CONTAINMENT_CENTER, numHexagons, hexagons);
t_assert(err == E_MEMORY_ALLOC,
"polygonToCellsExperimental failed (1)");
t_assert(actualAllocCalls == 1, "alloc called once");
t_assert(actualFreeCalls == 0, "free not called");

resetMemoryCounters(1);
err = H3_EXPORT(polygonToCellsExperimental)(
&sfGeoPolygon, 9, CONTAINMENT_CENTER, hexagons);
&sfGeoPolygon, 9, CONTAINMENT_CENTER, numHexagons, hexagons);
t_assert(err == E_SUCCESS, "polygonToCellsExperimental succeeded (1)");
t_assert(actualAllocCalls == 1, "alloc called one time");
t_assert(actualFreeCalls == 1, "free called one time");
Expand Down
Loading

0 comments on commit c8f1f72

Please sign in to comment.