|
From: Ioannis V. <iv...@em...> - 2003-07-10 12:12:31
|
> -----Original Message-----
> From: Per Westermark [mailto:pw...@ia...]
> Sent: Thursday, July 10, 2003 9:05 AM
> To: Ioannis Vranos
> Cc: Dev-C++ Mailing List
> Subject: RE: [Dev-C++] STL Map question
>
>
> Yes, with char* AddUser etc must do strdup() or similar of
> the strings, to
> make them available for the lifetime of the user objects.
>
> However, when locating entries, it doesn't matter if the
> strings sent in
> to the Find() have different addresses.
Yes. However the definition she suspects that has the bug:
bool UserList::DeleteUser(const char *pNick)
{
bool bRet = false;
if(m_mapUsers.size() > 0)
{
UserMap::iterator it = m_mapUsers.find(pNick);
if(it != m_mapUsers.end())
{
m_mapUsers.erase(it);
bRet = true;
}
}
return bRet;
}
As I said it is OK.
However the member functions
void AddUser(User *pUser);
User *FindUser(const char *pNick);
are a different story (I included in this list the DeleteUser() from
rashness).
Ioannis Vranos
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL 1: http://run.to/noicys
* Alternative URL 2: http://www.noicys.cjb.net
|