This is an automated email from the ASF dual-hosted git repository. serverglen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/brpc.git
The following commit(s) were added to refs/heads/master by this push: new 0a940cdc fix redis server example handler memory leak (#2370) 0a940cdc is described below commit 0a940cdc4b21a9e12ca52df87ae78c79ffc15b68 Author: Dongsheng He <ds_h...@163.com> AuthorDate: Thu Sep 7 13:17:54 2023 +0800 fix redis server example handler memory leak (#2370) --- example/redis_c++/redis_server.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/example/redis_c++/redis_server.cpp b/example/redis_c++/redis_server.cpp index 406ece56..6ebc3853 100644 --- a/example/redis_c++/redis_server.cpp +++ b/example/redis_c++/redis_server.cpp @@ -24,6 +24,7 @@ #include <butil/crc32c.h> #include <butil/strings/string_split.h> #include <gflags/gflags.h> +#include <memory> #include <unordered_map> #include <butil/time.h> @@ -110,9 +111,11 @@ private: int main(int argc, char* argv[]) { google::ParseCommandLineFlags(&argc, &argv, true); - RedisServiceImpl* rsimpl = new RedisServiceImpl; - rsimpl->AddCommandHandler("get", new GetCommandHandler(rsimpl)); - rsimpl->AddCommandHandler("set", new SetCommandHandler(rsimpl)); + RedisServiceImpl *rsimpl = new RedisServiceImpl; + auto get_handler =std::unique_ptr<GetCommandHandler>(new GetCommandHandler(rsimpl)); + auto set_handler =std::unique_ptr<SetCommandHandler>( new SetCommandHandler(rsimpl)); + rsimpl->AddCommandHandler("get", get_handler.get()); + rsimpl->AddCommandHandler("set", set_handler.get()); brpc::Server server; brpc::ServerOptions server_options; --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For additional commands, e-mail: dev-h...@brpc.apache.org