void THistDlg::SendNotify(HostSub *hostSub, ULONG packetNo) { #define MAX_OPENHISTORY 500 int num = histHash.GetRegisterNum(); if (num >= MAX_OPENHISTORY) { if (HistObj *obj = histHash.End()) { if (hWnd) histListView.DeleteItem(num-1); histHash.UnRegister(obj); if (!*obj->odate) unOpenedNum--; delete obj; num--; } } HistObj *obj = new HistObj(); int len = MakeHistInfo(hostSub, packetNo, obj->info); histHash.Register(obj, MakeHash(obj->info, len, 0)); MakeListString(cfg, hostSub, hosts, obj->user); SYSTEMTIME st; ::GetLocalTime(&st); sprintf(obj->sdate, "%02d/%02d %02d:%02d", st.wMonth, st.wDay, st.wHour, st.wMinute); sprintf(obj->pktno, "%x", packetNo); unOpenedNum++; if (hWnd) { if (!openedMode) { SetData(obj); } SetTitle(); } }
double DynamicResult(std::vector<bool>& visited ,int lastVisitedId, double beforeSum, int remainCity) { if (remainCity == 0) return 0.0; int hash = MakeHash(visited, lastVisitedId); if (cache[lastVisitedId][remainCity][hash] > 0.0) return cache[lastVisitedId][remainCity][hash]; double minResult = INF; int N = (int)visited.size(); for (int i = 0; i < N; i++) { if (visited[i] == false ) { visited[i] = true; double tmpVal = dist_map[lastVisitedId][i] + DynamicResult(visited, i, beforeSum + dist_map[lastVisitedId][i], remainCity - 1); minResult = std::min(minResult, tmpVal); visited[i] = false; } } cache[lastVisitedId][remainCity][hash] = minResult; return minResult; }
BOOL VerifyHash(const BYTE *data, int len, const char *orgHash) { char hash[MAX_NAMEBUF]; MakeHash(data, len, hash); return stricmp(hash, orgHash); }
bool HiScoreDb::Load(std::string filename) { // Load local hi score table m_hsVec.clear(); filename = GetSaveDir() + filename; File f(false, File::STD); if (!f.OpenRead(filename, false, false)) { f.ReportError("Failed to load hi scores!"); return false; } int n = 0; if (!f.GetInteger(&n)) { f.ReportError("Expected number of hi scores"); return false; } for (int i = 0; i < n; i++) { Hi hi; if (!hi.Load(&f)) { f.ReportError("Failed to load hi score line"); return false; } int hash = MakeHash(hi); hi.m_hash = hash; m_hsVec.push_back(hi); } return true; }
StageCollection(PipelineConverter<P>& conv, FactoryCtx& ctx, const I& in, typename std::enable_if_t<std::is_base_of_v<GeneralShader, I>>* = 0) { m_vertex = conv.getVertexConverter().convert(ctx, in); m_fragment = conv.getFragmentConverter().convert(ctx, in); m_vtxFmt = in.VtxFmt; m_additionalInfo = in.PipelineInfo; MakeHash(); }
void HiScoreDb::AddHiScore(const Hi& chi) { Hi hi(chi); int hash = MakeHash(hi); hi.m_hash = hash; m_hsVec.push_back(hi); std::sort(m_hsVec.begin(), m_hsVec.end()); }
CmdResult Handle (const std::vector<std::string>& parameters, User *user) { MakeHash(user, parameters[0].c_str(), parameters[1].c_str()); // this hashing could take some time, increasing server load. // Slow down the user if they are trying to flood mkpasswd requests user->IncreasePenalty(5); return CMD_LOCALONLY; }
CmdResult Handle (const char** parameters, int pcnt, userrec *user) { MakeHash(user, parameters[0], parameters[1]); /* NOTE: Don't propogate this across the network! * We dont want plaintext passes going all over the place... * To make sure it goes nowhere, return CMD_FAILURE! */ return CMD_FAILURE; }
void HiScoreDb::RemoveHiScore(const Hi& hi) { if (!m_hsVec.empty()) { int hash = MakeHash(hi); m_hsVec.erase( std::remove_if(m_hsVec.begin(), m_hsVec.end(), [=](const Hi& hi) { return hi.m_hash == hash; } ), m_hsVec.end()); } }
Graph MakeGraph(int numvert, int numproc) { int perproc = numvert/numproc; int i,j; int count1; Vertex v,tmp; Vertex block; Graph retval; #ifdef FUTURES future_cell_int fc[MAXPROC]; #endif retval = (Graph) ALLOC(0,sizeof(*retval)); for (i=0; i<MAXPROC; i++) { retval->vlist[i]=NULL; } chatting("Make phase 2\n"); for (j=numproc-1; j>=0; j--) { block = (Vertex) ALLOC(j,perproc*(sizeof(*tmp))); v = NULL; for (i=0; i<perproc; i++) { tmp = block+(perproc-i-1); HashRange = numvert/4; tmp->mindist = 9999999; tmp->edgehash = MakeHash(numvert/4,hashfunc); tmp->next = v; v=tmp; } retval->vlist[j] = v; } chatting("Make phase 3\n"); for (j=numproc-1; j>=0; j--) { count1 = j*perproc; #ifndef FUTURES AddEdges(count1, retval, numproc, perproc, numvert, j); #else FUTURE(count1,retval,numproc,perproc,numvert,j,AddEdges,&fc[j]); #endif } /* for j... */ chatting("Make phase 4\n"); #ifdef FUTURES for (j=0; j<numproc; j++) { TOUCH(&fc[j]); } #endif chatting("Make returning\n"); return retval; }
void HiScoreDb::Erase(const Hi& hi) { int hash = MakeHash(hi); for (auto it = m_hsVec.begin(); it != m_hsVec.end(); ++it) { if (it->m_hash == hash) { m_hsVec.erase(it); return; } } }
// Define this ANY value's type to the one that the given id hashes // to in the ANY table. void AsnAny::SetTypeByInt (const AsnInt& id) const { Hash hash; void *anyInfo; /* use int as hash string */ hash = MakeHash ((const char*)id.c_str(), id.length()); if (CheckForAndReturnValue (intHashTbl, hash, &anyInfo)) ai = (AnyInfo*) anyInfo; else ai = NULL; /* indicates failure */ } /* SetAnyTypeByInt */
StageCollection(PipelineConverter<P>& conv, FactoryCtx& ctx, const I& in, typename std::enable_if_t<std::conjunction_v<std::is_base_of<TessellationShader, I>, std::is_same<P, PlatformType::Metal>>>* = 0) { if (in.HasTessellation) { m_control = conv.getControlConverter().convert(ctx, in); m_evaluation = conv.getEvaluationConverter().convert(ctx, in); } else { m_vertex = conv.getVertexConverter().convert(ctx, in); } m_fragment = conv.getFragmentConverter().convert(ctx, in); m_vtxFmt = in.VtxFmt; m_additionalInfo = in.PipelineInfo; MakeHash(); }
// Define this ANY value's type to the one that the given id hashes // to in the ANY table. void AsnAny::SetTypeByOid (const AsnOid &id) const { Hash hash; void *anyInfo; /* use encoded oid as hash string */ hash = MakeHash (id.Str(), id.Len()); if (CheckForAndReturnValue (oidHashTbl, hash, &anyInfo)) ai = (AnyInfo*) anyInfo; else ai = NULL; /* indicates failure */ //RWC;4/16/01; lastly, clear ->value in case loaded previously. } /* SetAnyTypeByOid */
BOOL TInifile::Lock() { if (!hMutex) { char buf[1024]; char *key = (char *)_mbsrchr((u_char *)ini_file, '\\'); key = key ? key+1 : ini_file; sprintf(buf, "%s_%x", key, MakeHash(ini_file, (int)strlen(ini_file), 0)); if (!(hMutex = ::CreateMutex(NULL, FALSE, buf))) return FALSE; } return ::WaitForSingleObject(hMutex, INFINITE); }
BOOL TInifile::Lock() { if (!hMutex) { WCHAR buf[1024]; WCHAR *key = wcsrchr(iniFile, L'\\'); key = key ? key+1 : iniFile; swprintf(buf, L"%s_%x", key, MakeHash(iniFile, int(wcslen(iniFile) * sizeof(WCHAR)), 0)); if (!(hMutex = ::CreateMutexW(NULL, FALSE, buf))) return FALSE; } return ::WaitForSingleObject(hMutex, INFINITE); }
void THistDlg::OpenNotify(HostSub *hostSub, ULONG packetNo, char *notify) { char buf[MAX_BUF]; int len; u_int hash_val; HistObj *obj; int idx; len = MakeHistInfo(hostSub, packetNo, buf); hash_val = MakeHash(buf, len, 0); if (!(obj = (HistObj *)histHash.Search(buf, hash_val))) { SendNotify(hostSub, packetNo); if (!(obj = (HistObj *)histHash.Search(buf, hash_val))) { return; } sprintf(obj->sdate, GetLoadStrU8(IDS_UNKNOWN)); } if (*obj->odate) return; SYSTEMTIME st; ::GetLocalTime(&st); sprintf(obj->odate, "%02d/%02d %02d:%02d", st.wMonth, st.wDay, st.wHour, st.wMinute); if (--unOpenedNum < 0) unOpenedNum = 0; histHash.RegisterLru(obj); if (notify) { strncpyz(obj->sdate, obj->odate, sizeof(obj->sdate)); strncpyz(obj->odate, notify, sizeof(obj->odate)); } if (hWnd) { if (openedMode) { SetData(obj); } else { if ((idx = histListView.FindItem((LPARAM)obj)) >= 0) { histListView.DeleteItem(idx); } } SetTitle(); } }
Graph MakeGraph(int numvert, int numproc) { int perproc = numvert/numproc; int i,j; int count1; Vertex v,tmp; Vertex block; Graph retval; retval = (Graph)malloc(sizeof(*retval)); for (i=0; i<MAXPROC; i++) { retval->vlist[i]=NULL; } chatting("Make phase 2\n"); for (j=numproc-1; j>=0; j--) { block = (Vertex) malloc(perproc*(sizeof(*tmp))); v = NULL; for (i=0; i<perproc; i++) { tmp = block+(perproc-i-1); HashRange = numvert/4; tmp->mindist = 9999999; tmp->edgehash = MakeHash(numvert/4,hashfunc); tmp->next = v; v=tmp; } retval->vlist[j] = v; } chatting("Make phase 3\n"); for (j=numproc-1; j>=0; j--) { count1 = j*perproc; AddEdges(count1, retval, numproc, perproc, numvert, j); } /* for j... */ chatting("Make phase 4\n"); chatting("Make returning\n"); return retval; }
APCHandle::Pair APCArray::MakeSharedArray(ArrayData* arr, APCHandleLevel level, bool unserializeObj) { if (level == APCHandleLevel::Outer) { // only need to call traverseData() on the toplevel array DataWalker walker(DataWalker::LookupFeature::HasObjectOrResource); DataWalker::DataFeature features = walker.traverseData(arr); if (features.isCircular) { String s = apc_serialize(Variant{arr}); return APCString::MakeSerializedArray(s.get()); } if (apcExtension::UseUncounted && !features.hasObjectOrResource && !arr->empty()) { return {MakeUncountedArray(arr), getMemSize(arr) + sizeof(APCTypedValue)}; } } return arr->isVectorData() ? MakePacked(arr, unserializeObj) : MakeHash(arr, unserializeObj); }
// given an OBJECT IDENTIFIER, oid, to hash on, the type and it's anyId // are installed in the OBJECT IDENTIFIER id hash tbl void AsnAny::InstallAnyByOid (AsnOid &oid, int anyId, AsnType *type) { AnyInfo *a; Hash h; a = new AnyInfo; a->anyId = anyId; a->oid = oid; // copy given oid a->typeToClone = type; h = MakeHash (oid.Str(), oid.Len()); if (AsnAny::oidHashTbl == NULL) AsnAny::oidHashTbl = InitHash(); if (! Insert (AsnAny::oidHashTbl, a, h)) { delete a->typeToClone; delete a; } } /* InstallAnyByOid */
// Given an integer, intId, to hash on, the type and it's anyId // are installed in the integer id hash tbl void AsnAny::InstallAnyByInt (AsnIntType intId, int anyId, AsnType *type) { AnyInfo *a; Hash h; a = new AnyInfo; // Oid will be NULL and 0 len by default constructor a->anyId = anyId; a->intId = intId; a->typeToClone = type; if (AsnAny::intHashTbl == NULL) AsnAny::intHashTbl = InitHash(); AsnInt intval = intId; h = MakeHash ((const char*)intval.c_str(), intval.length()); if ( ! Insert (AsnAny::intHashTbl, a, h) ) { delete a->typeToClone; delete a; } } /* InstallAnyByInt */
CmdResult Handle (const std::vector<std::string>& parameters, User *user) { MakeHash(user, parameters[0], parameters[1]); return CMD_SUCCESS; }
unsigned LucKey::IntVector2ToHash(IntVector2 vec) { return (MakeHash(vec.x_) & 0xffff) | (MakeHash(vec.y_) << 16); }