Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leak in st_asgeojson, avoid copy #372

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions spatial/src/spatial/core/functions/scalar/st_asgeojson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,10 @@ static void GeometryToGeoJSONFragmentFunction(DataChunk &args, ExpressionState &
Geometry::Match<ToGeoJSONFunctor>(geom, doc, obj);

size_t json_size = 0;
// TODO: YYJSON_WRITE_PRETTY
auto json_data = yyjson_mut_write(doc, 0, &json_size);
auto json_str = StringVector::AddString(result, json_data, json_size);
return json_str;
char *json_data = yyjson_mut_write_opts(doc, 0, json_allocator.GetYYJSONAllocator(), &json_size, nullptr);
// Because the arena allocator only resets after each pipeline invocation, we can safely just point into the
// arena here without needing to copy the data to the string heap with StringVector::AddString
return string_t(json_data, json_size);
});
}

Expand Down
Loading