Big Bug!!!

Post here your questions about the C++ API for SFS2X

Moderators: Lapo, Bax, MBagnati

Post Reply
balder
Posts: 13
Joined: 10 Nov 2012, 03:36

Big Bug!!!

Post by balder »

Big Bug!!!!!!
In c++ client api, why so many new ? many infos returned from the api is new . why not use the value ,not the pointers? Or, why not use stl 's smart pointer?
The SFSRoom::PlayerList and SFSRoom::SpectatorList()

Code: Select all

for (iterator = userManager->GetUserList()->begin(); iterator != userManager->GetUserList()->end(); iterator++)
{
....
}
//File SFSUserManager.cpp  line:178
vector<User *> *SFSUserManager::GetUserList()
{
     vector<User *>* result = new vector<User *>();
......
}
when userManager->GetUserList() called, it will return a new vector<User *> . It loops n times, will leak n times vector<User *>,It's Horrible!!!
balder
Posts: 13
Joined: 10 Nov 2012, 03:36

Re: Big Bug!!!

Post by balder »

the version is the latest version 0.9.5
MBagnati
Posts: 126
Joined: 12 Feb 2013, 10:57

Re: Big Bug!!!

Post by MBagnati »

We are already investigating how simplify the usage of pointers as function parameters, following suggestions incoming from you and from other users, to get two goals:
first to have a general guideline about who is responsible to release memory to avoid leaks;
second to give a more confortable API interface.

Please give us a little time to study the question and fix it into the next API release
balder
Posts: 13
Joined: 10 Nov 2012, 03:36

Re: Big Bug!!!

Post by balder »

why using the pointers. Using the value parameter is a good idea. i think the smartfox client api can make a copy of data from the client,not using the pointers from the client side,then the api side can using the memory pool to speed memory allocation! The speed penalty is very small,or can saved by using the memory pool.
MBagnati
Posts: 126
Joined: 12 Feb 2013, 10:57

Re: Big Bug!!!

Post by MBagnati »

Version 0.9.6 contains a review of API interface to improve this issue
Post Reply