File tree Expand file tree Collapse file tree 4 files changed +11
-17
lines changed
example/client-cpp-example/src
iotdb-client/client-cpp/src/main Expand file tree Collapse file tree 4 files changed +11
-17
lines changed Original file line number Diff line number Diff line change 2222
2323using namespace std ;
2424
25- TableSession * session;
25+ shared_ptr< TableSession> session;
2626
2727void insertRelationalTablet () {
2828
@@ -203,8 +203,6 @@ int main() {
203203 cout << " session close\n " << endl;
204204 session->close ();
205205
206- delete session;
207-
208206 cout << " finished!\n " << endl;
209207 } catch (IoTDBConnectionException &e) {
210208 cout << e.what () << endl;
Original file line number Diff line number Diff line change @@ -79,12 +79,12 @@ class SessionBuilder : public AbstractSessionBuilder {
7979 return this ;
8080 }
8181
82- Session* build () {
82+ std::shared_ptr< Session> build () {
8383 sqlDialect = " tree" ;
84- Session* newSession = new Session (this );
84+ auto newSession = std::make_shared< Session> (this );
8585 newSession->open (false );
8686 return newSession;
87- }
87+ }
8888};
8989
9090#endif // IOTDB_SESSION_BUILDER_H
Original file line number Diff line number Diff line change 2626
2727class TableSession {
2828private:
29- Session* session_;
29+ std::shared_ptr< Session> session_;
3030 string getDatabase ();
3131public:
32- TableSession (Session* session) {
32+ TableSession (std::shared_ptr< Session> session) {
3333 this ->session_ = session;
3434 }
35- ~TableSession () {
36- if (session_) {
37- delete session_;
38- session_ = nullptr ;
39- }
40- }
35+ ~TableSession () {}
36+
4137 void insert (Tablet& tablet, bool sorted = false );
4238 void executeNonQueryStatement (const std::string& sql);
4339 unique_ptr<SessionDataSet> executeQueryStatement (const std::string& sql);
Original file line number Diff line number Diff line change @@ -69,11 +69,11 @@ class TableSessionBuilder : public AbstractSessionBuilder {
6969 AbstractSessionBuilder::nodeUrls = nodeUrls;
7070 return this ;
7171 }
72- TableSession* build () {
72+ std::shared_ptr< TableSession> build () {
7373 sqlDialect = " table" ;
74- Session* newSession = new Session (this );
74+ auto newSession = std::make_shared< Session> (this );
7575 newSession->open (false );
76- return new TableSession (newSession);
76+ return std::make_shared< TableSession> (newSession);
7777 }
7878};
7979
You can’t perform that action at this time.
0 commit comments