1
0
Fork 0

stdlib: Add Lth_Hash_char

master
Marrub 2016-10-19 10:03:32 -04:00
parent ca89eb95e9
commit 81061174e9
2 changed files with 18 additions and 0 deletions

View File

@ -25,4 +25,7 @@ __str Lth_strlocal(__str s);
// Print
void Lth_PrintString(char const *s);
// Hash
size_t Lth_Hash_char(char const *s);
#endif//lithos3__Lth_stdlib_h

View File

@ -83,4 +83,19 @@ void Lth_PrintString(char const *s)
for(char const *p = s; *p;) ACS_PrintChar(*p++);
}
//
// Lth_Hash_char
//
size_t Lth_Hash_char(char const *s)
{
if(s == NULL) return 0;
size_t ret = 0;
while(*s)
ret = ret * 101 + (unsigned char)(*s++);
return ret;
}
// EOF