Changeset a73aaec1 in mainline
- Timestamp:
- 2020-04-13T20:52:27Z (5 years ago)
- Children:
- 81c4e6ec
- Parents:
- aa0faeca
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/adt/hash.h
raa0faeca ra73aaec1 115 115 * TODO Modify also same file in kernel subtree? 116 116 * 117 * @param[in] str NULL-terminated string (not NULL) 117 * @param[in] str NULL-terminated string 118 * @return hash of the given string 118 119 */ 119 120 static inline size_t hash_string(const char *str) 120 121 { 121 /* 122 * Using djb2 function 123 * http://www.cse.yorku.ca/~oz/hash.html 124 */ 125 size_t hash = 5381; 126 char c; 127 while ((c = *str++)) { 128 hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ 122 size_t hash = 0; 123 if (str != NULL) { 124 char c; 125 while ((c = *str++) != 0) { 126 hash = hash_combine(hash, c); 127 } 129 128 } 129 130 130 return hash; 131 131 }
Note:
See TracChangeset
for help on using the changeset viewer.