sync udp2raw bugfix

This commit is contained in:
yancey 2023-07-22 14:45:53 -04:00
parent 3ac5e6b40d
commit c3debb0290

View File

@ -895,8 +895,8 @@ int new_connected_socket2(int &fd, address_t &addr, address_t *bind_addr, char *
u32_t djb2(unsigned char *str, int len) { u32_t djb2(unsigned char *str, int len) {
u32_t hash = 5381; u32_t hash = 5381;
int c; int c;
int i = 0; for (int i=0; i<len ;i++) {
while (c = *str++, i++ != len) { c = *(str++);
hash = ((hash << 5) + hash) ^ c; /* (hash * 33) ^ c */ hash = ((hash << 5) + hash) ^ c; /* (hash * 33) ^ c */
} }
@ -907,14 +907,15 @@ u32_t djb2(unsigned char *str, int len) {
u32_t sdbm(unsigned char *str, int len) { u32_t sdbm(unsigned char *str, int len) {
u32_t hash = 0; u32_t hash = 0;
int c; int c;
int i = 0; for (int i=0; i<len ;i++) {
while (c = *str++, i++ != len) { c = *(str++);
hash = c + (hash << 6) + (hash << 16) - hash; hash = c + (hash << 6) + (hash << 16) - hash;
} }
// hash=htonl(hash); // hash=htonl(hash);
return hash; return hash;
} }
vector<string> string_to_vec(const char *s, const char *sp) { vector<string> string_to_vec(const char *s, const char *sp) {
vector<string> res; vector<string> res;
string str = s; string str = s;