T& GetT() { if (!m_Inited) { Init(); } unsigned int *pAddr[PRO_MAX] = {0};//Ò»¶ÑµØÖ· pAddr[GetCnt() - 1] = (unsigned int*)m_Base; for (int i =GetCnt() - 1 -1;i >=0;--i ) { pAddr[i] = (unsigned int*)(void*)(*pAddr[i+1]); } return *(T*)pAddr[0]; }
void GetRealCnt(int* realCnt) { uint8_t i; for (i = 0; i < 4; i++) { realCnt[i]=GetCnt(g_motorAddress[i]); } }
void Init() { T *pT = (T*)malloc(sizeof(T)) ; unsigned int *pAddr[PRO_MAX];//Ò»¶ÑµØÖ· for (int i = 0; i < PRO_MAX; ++i) { pAddr[i] = (unsigned int*)malloc(sizeof(unsigned int)); } *pAddr[0] = (unsigned int)pT; for (int i = 1; i < PRO_MAX; ++i) { *pAddr[i] = (unsigned int)pAddr[i-1]; } SetCnt(GetTickCount() % PRO_LIMIT1 + PRO_LIMIT2); m_Base = (unsigned int)pAddr[GetCnt() - 1]; m_Inited = 1; }