stdlib: Add Lth_Hash_char
parent
ca89eb95e9
commit
81061174e9
|
@ -25,4 +25,7 @@ __str Lth_strlocal(__str s);
|
||||||
// Print
|
// Print
|
||||||
void Lth_PrintString(char const *s);
|
void Lth_PrintString(char const *s);
|
||||||
|
|
||||||
|
// Hash
|
||||||
|
size_t Lth_Hash_char(char const *s);
|
||||||
|
|
||||||
#endif//lithos3__Lth_stdlib_h
|
#endif//lithos3__Lth_stdlib_h
|
||||||
|
|
|
@ -83,4 +83,19 @@ void Lth_PrintString(char const *s)
|
||||||
for(char const *p = s; *p;) ACS_PrintChar(*p++);
|
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
|
// EOF
|
||||||
|
|
Loading…
Reference in New Issue