static unsigned int __fastcall hashstrW(const char *key) { if (key == NULL) return 0; const unsigned int len = (unsigned int)wcslen((const wchar_t*)key); char *buf = (char*)alloca(len + 1); for (unsigned i = 0; i <= len; ++i) buf[i] = key[i << 1]; return mir_hash(buf, len); }
ImageBase* AddCacheImage(const CMString& file, int index) { CMString tmpfile(file); tmpfile.AppendFormat(_T("#%d"), index); unsigned id = mir_hash(tmpfile.c_str(), tmpfile.GetLength() * sizeof(TCHAR)); WaitForSingleObject(g_hMutexIm, 3000); ImageBase srch(id); ImageBase *img = g_imagecache.find(&srch); if (img == NULL) { int ind = file.ReverseFind('.'); if (ind == -1) return NULL; CMString ext = file.Mid(ind+1); ext.MakeLower(); if (ext == _T("dll") || ext == _T("exe")) img = opt.HQScaling ? (ImageBase*)new ImageType(id, file, index, icoDll) : (ImageBase*)new IconType(id, file, index, icoDll); else if (ext == _T("ico")) img = opt.HQScaling ? (ImageBase*)new ImageType(id, file, 0, icoFile) : (ImageBase*)new IconType(id, file, 0, icoFile); else if (ext == _T("icl")) img = opt.HQScaling ? (ImageBase*)new ImageType(id, file, index, icoIcl) : (ImageBase*)new IconType(id, file, index, icoIcl); else if (ext == _T("gif")) img = new ImageType(id, file, NULL); else if (fei == NULL || ext == _T("tif") || ext == _T("tiff")) img = new ImageType(id, file, NULL); else img = opt.HQScaling ? (ImageBase*)new ImageType(id, file, NULL) : (ImageBase*)new ImageFType(id, file); g_imagecache.insert(img); if (timerId == 0) { timerId = 0xffffffff; CallFunctionAsync(sttMainThreadCallback, NULL); } } else img->AddRef(); ReleaseMutex(g_hMutexIm); return img; }