ctci::string ctci::operator+=(ctci::string& s1, const ctci::string& s2) { int l = s1.size() + s2.size() + 1; char* c = (char*)calloc(l, 1); memcpy(c, s1.buf, s1.size()); memcpy(c+s1.size(), s2.buf, s2.size()); s1.buf = c; return s1; }
ctci::string ctci::operator+(const ctci::string& s1, const ctci::string& s2) { ctci::string str; free(str.buf); str.buf = 0; size_t l = s1.size()+s2.size()+1; str.buf = (char*)calloc(l, 1); memcpy(str.buf, s1.buf, s1.size()); memcpy(str.buf+s1.size(), s2.buf, s2.size()); return str; }
unsigned int hash_table<V>::hash(const ctci::string& k) const { unsigned int val = 0; for (size_t i = 0; i < k.size(); i++) { val += abs(int(k[i])); } return val; }