vfs: check userland buffers before reading them.
[haiku.git] / src / kits / debugger / util / StringUtils.cpp
blob7e1eb47d2b5c3e8edd3dc6138c43b7d4a0a10182
1 /*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
6 #include "StringUtils.h"
9 // from the Dragon Book: a slightly modified hashpjw()
10 /*static*/ uint32
11 StringUtils::HashValue(const char* string)
13 if (string == NULL)
14 return 0;
16 uint32 h = 0;
18 for (; *string; string++) {
19 uint32 g = h & 0xf0000000;
20 if (g)
21 h ^= g >> 24;
22 h = (h << 4) + *string;
25 return h;