Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / apps / drwho / HT_Client.cpp
blob323939372b0c459d38db8e2f3c5e96ec57206fb7
1 #include "HT_Client.h"
2 #include "ace/ACE.h"
3 #include "ace/OS_NS_string.h"
4 #include "ace/OS_Memory.h"
6 // Insert a KEY_NAME into the hash table, if it doesn't already exist
7 // there. What gets returned is a pointer to the node inserted. Note
8 // that we do our own memory allocation here...
10 Protocol_Record *
11 HT_Client::insert (const char *key_name, int max_len)
13 Protocol_Record **prpp = 0;
15 // This is tricky...
17 for (prpp = &this->hash_table[ACE::hash_pjw (key_name) % this->hash_table_size];
18 *prpp != 0
19 && ACE_OS::strncmp ((*prpp)->get_login (),
20 key_name, max_len) != 0;
21 prpp = &(*prpp)->next_)
22 continue;
24 if (*prpp == 0)
26 ACE_NEW_RETURN (*prpp,
27 Protocol_Record (ACE::strnew (key_name),
28 *prpp),
29 0);
30 this->count_++;
33 return *prpp;