gpt-3.5-turbo-0301· OpenAI
WildChat-4.8M (AI2)
refactor code below ,bool SntlLicGenPrivate::clearBuffer(int startIdx, int ulSize, const…
- User
refactor code below ,bool SntlLicGenPrivate::clearBuffer(int startIdx, int ulSize, const unsigned long featId) { unsigned char *buffer = new unsigned char[ulSize]; for(int i = 0; i < ulSize; i++){ buffer[i] = 0x00; }
bool succ = false; ChaspFeature feature = ChaspFeature::fromFeature(featId); Chasp hasp(feature); const string scope = getProdIdScope(); auto status = hasp.login(vendorCode, scope); if(HASP_SUCCEEDED(status)){ ChaspFile file = hasp.getFile(ChaspFile::fileReadWrite); file.setFilePos(startIdx); status = file.write(buffer, ulSize); if(HASP_SUCCEEDED(status)) succ = true; } delete[] buffer; hasp.logout(); setHaspSt(status); return succ;},stl 容器替代char数组
- Assistant
bool SntlLicGenPrivate::clearBuffer(int startIdx, int ulSize, const unsigned long featId) { vector buffer(ulSize, 0x00);
bool succ = false; ChaspFeature feature = ChaspFeature::fromFeature(featId); Chasp hasp(feature); const string scope = getProdIdScope(); auto status = hasp.login(vendorCode, scope); if (HASP_SUCCEEDED(status)) { ChaspFile file = hasp.getFile(ChaspFile::fileReadWrite); file.setFilePos(startIdx); status = file.write(&buffer[0], ulSize); if (HASP_SUCCEEDED(status)) succ = true; } hasp.logout(); setHaspSt(status); return succ;}