Changeset 59ba708 in mainline
- Timestamp:
- 2019-08-03T07:53:46Z (5 years ago)
- Children:
- 6006f35
- Parents:
- 6efec7e3
- git-author:
- Michal Koutný <xm.koutny+hos@…> (2015-04-15 15:04:28)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2019-08-03 07:53:46)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/adt/hash.h
r6efec7e3 r59ba708 111 111 } 112 112 113 /** Calculate hash of NULL-terminated string 114 * 115 * TODO Modify also same file in kernel subtree? 116 * 117 * @param[in] str NULL-terminated string (not NULL) 118 */ 119 static inline size_t hash_string(const char *str) 120 { 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 */ 129 } 130 return hash; 131 } 132 113 133 #endif
Note:
See TracChangeset
for help on using the changeset viewer.