Skip to content

Commit 72c8258

Browse files
authored
fix: TableFunction leak (#3648)
`tf` is copied by value and does not need to be heap allocated. Signed-off-by: Alexander Droste <[email protected]>
1 parent 513e456 commit 72c8258

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

vortex-duckdb/cpp/table_function.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -227,34 +227,34 @@ extern "C" duckdb_state duckdb_vx_tfunc_register(duckdb_connection ffi_conn,
227227
}
228228

229229
auto conn = reinterpret_cast<Connection *>(ffi_conn);
230-
auto tf = new TableFunction(vtab->name, {}, c_function, c_bind, c_init_global, c_init_local);
230+
auto tf = TableFunction(vtab->name, {}, c_function, c_bind, c_init_global, c_init_local);
231231

232-
tf->pushdown_complex_filter = c_pushdown_complex_filter;
232+
tf.pushdown_complex_filter = c_pushdown_complex_filter;
233233

234-
tf->projection_pushdown = vtab->projection_pushdown;
235-
tf->filter_pushdown = vtab->filter_pushdown;
236-
tf->filter_prune = vtab->filter_prune;
237-
tf->sampling_pushdown = vtab->sampling_pushdown;
238-
tf->late_materialization = vtab->late_materialization;
234+
tf.projection_pushdown = vtab->projection_pushdown;
235+
tf.filter_pushdown = vtab->filter_pushdown;
236+
tf.filter_prune = vtab->filter_prune;
237+
tf.sampling_pushdown = vtab->sampling_pushdown;
238+
tf.late_materialization = vtab->late_materialization;
239239

240240
// Set up the parameters
241241
for (size_t i = 0; i < vtab->parameter_count; i++) {
242242
auto logical_type = reinterpret_cast<LogicalType *>(vtab->parameters[i]);
243-
tf->arguments.push_back(*logical_type);
243+
tf.arguments.push_back(*logical_type);
244244
}
245245
// And the named parameters
246246
for (size_t i = 0; i < vtab->named_parameter_count; i++) {
247247
auto logical_type = reinterpret_cast<LogicalType *>(vtab->named_parameter_types[i]);
248-
tf->named_parameters.insert({vtab->named_parameter_names[i], *logical_type});
248+
tf.named_parameters.insert({vtab->named_parameter_names[i], *logical_type});
249249
}
250250

251251
// Assign the VTable to the function info so we can access it later to invoke the callbacks.
252-
tf->function_info = make_shared_ptr<CTableFunctionInfo>(*vtab);
252+
tf.function_info = make_shared_ptr<CTableFunctionInfo>(*vtab);
253253

254254
try {
255255
conn->context->RunFunctionInTransaction([&]() {
256256
auto &catalog = Catalog::GetSystemCatalog(*conn->context);
257-
CreateTableFunctionInfo tf_info(*tf);
257+
CreateTableFunctionInfo tf_info(tf);
258258
catalog.CreateTableFunction(*conn->context, tf_info);
259259
});
260260
} catch (...) {

0 commit comments

Comments
 (0)