netconf-c++: simplify <get-config/> implementation
Change-Id: I0e500bb90be1344a0c4bf2ab78dc6ea503461acf
diff --git a/src/netconf-client.cpp b/src/netconf-client.cpp
index 3ced537..096b929 100644
--- a/src/netconf-client.cpp
+++ b/src/netconf-client.cpp
@@ -315,14 +315,9 @@
throw std::runtime_error("Cannot create get-config RPC");
}
auto reply = impl::do_rpc_data(this, std::move(rpc));
- // TODO: can we do without copying?
- // If we just default-construct a new node (or use the create_new_Data_Node) and then set reply->data to nullptr,
- // there are mem leaks and even libnetconf2 complains loudly.
auto dataNode = libyang::create_new_Data_Node(reply->data);
- if (!dataNode)
- return nullptr;
- else
- return dataNode->dup_withsiblings(1);
+ // TODO: can we do without copying? See Session::get() for details.
+ return dataNode ? dataNode->dup_withsiblings(1) : nullptr;
}
void Session::editConfig(const NC_DATASTORE datastore,