mail[Wesnoth-commits] r28613 - in /trunk/src/server: ban.cpp ban.hpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by paniemin on August 15, 2008 - 21:40:
Author: suokko
Date: Fri Aug 15 21:40:35 2008
New Revision: 28613

URL: http://svn.gna.org/viewcvs/wesnoth?rev=28613&view=rev
Log:
Made ban_manager to use shared_ptr to prevent memory leaks

Modified:
    trunk/src/server/ban.cpp
    trunk/src/server/ban.hpp

Modified: trunk/src/server/ban.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/ban.cpp?rev=28613&r1=28612&r2=28613&view=diff
==============================================================================
--- trunk/src/server/ban.cpp (original)
+++ trunk/src/server/ban.cpp Fri Aug 15 21:40:35 2008
@@ -25,7 +25,7 @@
 
        bool banned_compare::operator()(const banned_ptr a, const banned_ptr 
b) const
        {
-               return (*a) > (*b) || a->get_end_time() == 0;
+               return (*a) > (*b);
        }
 
        banned::banned(const std::string& ip, const time_t end_time, const 
std::string& reason) : ip_(ip), end_time_(end_time), reason_(reason), 
deleted_(false)
@@ -237,8 +237,7 @@
                {
                        banned_ptr ban = time_queue_.top();
 
-                       if (ban->get_end_time() == 0
-                               || ban->get_end_time() > time_now)
+                       if (ban->get_end_time() > time_now)
                        {
                                // No bans going to expire
                                LOG_SERVER << "ban " << ban->get_ip() << " 
not removed. time: " << time_now << " end_time " << ban->get_end_time() << 
"\n";

Modified: trunk/src/server/ban.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/ban.hpp?rev=28613&r1=28612&r2=28613&view=diff
==============================================================================
--- trunk/src/server/ban.hpp (original)
+++ trunk/src/server/ban.hpp Fri Aug 15 21:40:35 2008
@@ -18,19 +18,23 @@
 #include <queue>
 #include <ctime>
 
+#include <boost/shared_ptr.hpp>
+
 class config;
 
 namespace wesnothd {
 
        class banned;
 
+       typedef boost::shared_ptr<banned> banned_ptr;
+
        //! We want to move the lowest value to the top
        struct banned_compare {
-               bool operator()(const banned* a, const banned* b) const;
+               bool operator()(const banned_ptr a, const banned_ptr b) const;
        };
 
-       typedef std::map<std::string, banned*> ban_map;
-       typedef std::priority_queue<banned*,std::vector<banned*>, 
banned_compare> ban_time_queue;
+       typedef std::map<std::string, banned_ptr> ban_map;
+       typedef std::priority_queue<banned_ptr,std::vector<banned_ptr>, 
banned_compare> ban_time_queue;
        typedef std::map<std::string, size_t> default_ban_times;
 
 




Related Messages


Powered by MHonArc, Updated Fri Aug 15 23:01:52 2008