We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
class SqlConnRAII { public: SqlConnRAII(MYSQL** sql, SqlConnPool *connpool) { assert(connpool); *sql = connpool->GetConn(); sql_ = *sql; connpool_ = connpool; } ~SqlConnRAII() { if(sql_) { connpool_->FreeConn(sql_); } } private: MYSQL *sql_; SqlConnPool* connpool_; };
这里采用的是初始化外部变量sql的做法,会FreeConn(sql)执行了两次。为什么不把SqlConnRAII写成unique_ptr那种智能指针的形式呢。
如源码这里,定义了一个匿名变量,那析构函数就会立刻执行,那sql就会立刻被释放,而后源码中又执行了一次FreeConn。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
这里采用的是初始化外部变量sql的做法,会FreeConn(sql)执行了两次。为什么不把SqlConnRAII写成unique_ptr那种智能指针的形式呢。
如源码这里,定义了一个匿名变量,那析构函数就会立刻执行,那sql就会立刻被释放,而后源码中又执行了一次FreeConn。
The text was updated successfully, but these errors were encountered: