arpadboda commented on a change in pull request #462: MINIFICPP-695 - NanoFi
Examples appear to be broken
URL: https://github.com/apache/nifi-minifi-cpp/pull/462#discussion_r242586261
##########
File path: nanofi/src/api/nanofi.cpp
##########
@@ -167,66 +205,70 @@ int set_instance_property(nifi_instance *instance, const
char *key, const char *
* @param instance nifi instance.
*/
void free_instance(nifi_instance* instance) {
- if (instance != nullptr) {
- delete ((minifi::Instance*) instance->instance_ptr);
- free(instance->port.port_id);
- free(instance);
- }
+ NULL_CHECK(, instance);
+ delete ((minifi::Instance*) instance->instance_ptr);
+ free(instance->port.port_id);
+ free(instance);
}
/**
* Creates a flow file record
* @param file file to place into the flow file.
*/
flow_file_record* create_flowfile(const char *file, const size_t len) {
- flow_file_record *new_ff = (flow_file_record*)
malloc(sizeof(flow_file_record));
- new_ff->attributes = new string_map();
- new_ff->contentLocation = (char*) malloc(sizeof(char) * (len + 1));
- snprintf(new_ff->contentLocation, len + 1, "%s", file);
+ NULL_CHECK(nullptr, file);
std::ifstream in(file, std::ifstream::ate | std::ifstream::binary);
- // set the size of the flow file.
- new_ff->size = in.tellg();
- new_ff->keepContent = 0;
- return new_ff;
+ uint64_t file_size = in.tellg();
+ return create_ff_object(file, len, file_size);
}
/**
* Creates a flow file record
* @param file file to place into the flow file.
*/
flow_file_record* create_ff_object(const char *file, const size_t len, const
uint64_t size) {
- if (nullptr == file) {
- return nullptr;
- }
+ NULL_CHECK(nullptr, file);
flow_file_record *new_ff = create_ff_object_na(file, len, size);
new_ff->attributes = new string_map();
- new_ff->ffp = 0;
return new_ff;
}
flow_file_record* create_ff_object_na(const char *file, const size_t len,
const uint64_t size) {
Review comment:
This became the "construtor" to avoid duplication of member initializations.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services