Github user phrocker commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/432#discussion_r231866668 --- Diff: nanofi/src/api/nanofi.cpp --- @@ -323,55 +360,45 @@ int transmit_flowfile(flow_file_record *ff, nifi_instance *instance) { flow * create_new_flow(nifi_instance * instance) { auto minifi_instance_ref = static_cast<minifi::Instance*>(instance->instance_ptr); - flow *new_flow = (flow*) malloc(sizeof(flow)); - - auto execution_plan = new ExecutionPlan(minifi_instance_ref->getContentRepository(), minifi_instance_ref->getNoOpRepository(), minifi_instance_ref->getNoOpRepository()); - - new_flow->plan = execution_plan; - - return new_flow; + return new flow(minifi_instance_ref->getContentRepository(), minifi_instance_ref->getNoOpRepository(), minifi_instance_ref->getNoOpRepository()); --- End diff -- https://issues.apache.org/jira/browse/MINIFICPP-645 exists because public facing objects that are turned from a C API can be malloc'd by users. If a consumer of our API doesn't use free as designed, we should guarantee that they only cause memory leaks, not introduce undefined behavior.
---