Skip to content

Commit a1d2c26

Browse files
committed
修正controllers未正确释放内存的bug。
1 parent f394ac0 commit a1d2c26

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎kbe/src/server/cellapp/controllers.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ bool Controllers::add(Controller* pController)
4242
if(id == 0)
4343
id = freeID();
4444

45-
objects_[id] = pController;
45+
objects_[id].reset(pController);
4646
pController->id(id);
4747
return true;
4848
}
@@ -65,7 +65,7 @@ void Controllers::update()
6565
{
6666
AUTO_SCOPED_PROFILE("updateControllers");
6767

68-
std::map<uint32, Controller*>::iterator iter = objects_.begin();
68+
std::map<uint32, KBEShared_ptr< Controller > >::iterator iter = objects_.begin();
6969
for(; iter != objects_.end(); iter++)
7070
{
7171
iter->second->update();

‎kbe/src/server/cellapp/controllers.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Controllers
3939

4040
uint32 freeID(){ return ++lastid_; }
4141
private:
42-
std::map<uint32, Controller*> objects_;
42+
std::map<uint32, KBEShared_ptr< Controller > > objects_;
4343

4444
uint32 lastid_;
4545
};

0 commit comments

Comments
 (0)