本文整理汇总了C++中ReleaseMem函数的典型用法代码示例。如果您正苦于以下问题:C++ ReleaseMem函数的具体用法?C++ ReleaseMem怎么用?C++ ReleaseMem使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ReleaseMem函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PayloadsUninitialize
extern "C" void PayloadsUninitialize(
__in BURN_PAYLOADS* pPayloads
)
{
if (pPayloads->rgPayloads)
{
for (DWORD i = 0; i < pPayloads->cPayloads; ++i)
{
BURN_PAYLOAD* pPayload = &pPayloads->rgPayloads[i];
ReleaseStr(pPayload->sczKey);
ReleaseStr(pPayload->sczFilePath);
ReleaseMem(pPayload->pbHash);
ReleaseMem(pPayload->pbCertificateRootThumbprint);
ReleaseMem(pPayload->pbCertificateRootPublicKeyIdentifier);
ReleaseStr(pPayload->sczSourcePath);
ReleaseStr(pPayload->sczLocalFilePath);
ReleaseStr(pPayload->downloadSource.sczUrl);
ReleaseStr(pPayload->downloadSource.sczUser);
ReleaseStr(pPayload->downloadSource.sczPassword);
}
MemFree(pPayloads->rgPayloads);
}
// clear struct
memset(pPayloads, 0, sizeof(BURN_PAYLOADS));
}
示例2: ReleaseMem
void Context::Deallocate(void* ptr, std::size_t size)
{
if (POOL && size < 8192)
{
std::vector<void*>& poolForSize = pools[size];
if (poolForSize.size() < 16384)
poolForSize.push_back(ptr);
else
ReleaseMem(ptr);
}
else
{
ReleaseMem(ptr);
}
}
示例3: SendApplicationMessage
/******************************************************************
SendApplicationMessage - helper function to iterate through the
processes for the specified application and send all
applicable process Ids a message and give them time to process
the message.
******************************************************************/
void SendApplicationMessage(
__in LPCWSTR wzApplication,
__in DWORD dwMessageId,
__in DWORD dwTimeout
)
{
DWORD *prgProcessIds = NULL;
DWORD cProcessIds = 0, iProcessId;
HRESULT hr = S_OK;
WcaLog(LOGMSG_VERBOSE, "Checking App: %ls ", wzApplication);
hr = ProcFindAllIdsFromExeName(wzApplication, &prgProcessIds, &cProcessIds);
if (SUCCEEDED(hr) && 0 < cProcessIds)
{
WcaLog(LOGMSG_VERBOSE, "App: %ls found running, %d processes, attempting to send message.", wzApplication, cProcessIds);
for (iProcessId = 0; iProcessId < cProcessIds; ++iProcessId)
{
SendProcessMessage(prgProcessIds[iProcessId], dwMessageId, dwTimeout);
}
ProcWaitForIds(prgProcessIds, cProcessIds, dwTimeout);
}
ReleaseMem(prgProcessIds);
}
示例4: ReleaseMem
// ================================================================================
// FUNCTION : ResetContact
// DESCRIPTION : Reset the resource associate with contact.
// ================================================================================
void CContactInfo::ResetContact()
{
ReleaseMem();
m_nContactId = 0;
m_psFName = NULL;
m_psMName = NULL;
m_psLName = NULL;
m_psCompany = NULL;
m_psJTitle = NULL;
m_psFaxH = NULL;
m_psFaxW = NULL;
m_psFax = NULL;
m_psMobileH = NULL;
m_psMobileW = NULL;
m_psMobile = NULL;
m_psTelephoneH = NULL;
m_psTelephoneW = NULL;
m_psTelephone = NULL;
m_psEmailW = NULL;
m_psEmailH = NULL;
m_psEmail = NULL;
m_nState = SM_DBERROR;
m_psGlobalId = NULL;//invalid global id
}
示例5: MspEnginePackageUninitialize
extern "C" void MspEnginePackageUninitialize(
__in BURN_PACKAGE* pPackage
)
{
ReleaseStr(pPackage->Msp.sczPatchCode);
ReleaseStr(pPackage->Msp.sczApplicabilityXml);
// free properties
if (pPackage->Msp.rgProperties)
{
for (DWORD i = 0; i < pPackage->Msp.cProperties; ++i)
{
BURN_MSIPROPERTY* pProperty = &pPackage->Msp.rgProperties[i];
ReleaseStr(pProperty->sczId);
ReleaseStr(pProperty->sczValue);
ReleaseStr(pProperty->sczRollbackValue);
}
MemFree(pPackage->Msp.rgProperties);
}
// free target products
ReleaseMem(pPackage->Msp.rgTargetProducts);
// clear struct
memset(&pPackage->Msp, 0, sizeof(pPackage->Msp));
}
示例6: ExpectFile
void CfgTest::CheckCfgAndFile(CFGDB_HANDLE cdhDb, LPCWSTR wzFileName, LPCWSTR wzFilePath, BYTE *pbBuffer, SIZE_T cbBuffer)
{
HRESULT hr = S_OK;
BYTE *pbDataReadFromFile = NULL;
DWORD cbDataReadFromFile = 0;
ExpectFile(cdhDb, wzFileName, pbBuffer, cbBuffer);
hr = FileRead(&pbDataReadFromFile, &cbDataReadFromFile, wzFilePath);
ExitOnFailure1(hr, "Failed to read file: %ls", wzFilePath);
if (cbBuffer != cbDataReadFromFile)
{
hr = E_FAIL;
ExitOnFailure3(hr, "File %ls should be size %u, but was size %u instead", wzFilePath, cbBuffer, cbDataReadFromFile);
}
if (0 != memcmp(pbBuffer, pbDataReadFromFile, cbBuffer))
{
hr = E_FAIL;
ExitOnFailure1(hr, "File contents don't match for file of name: %ls", wzFilePath);
}
LExit:
ReleaseMem(pbDataReadFromFile);
}
示例7: ParseWxl
static HRESULT ParseWxl(
__in IXMLDOMDocument* pixd,
__out WIX_LOCALIZATION** ppWixLoc
)
{
HRESULT hr = S_OK;
IXMLDOMElement *pWxlElement = NULL;
WIX_LOCALIZATION* pWixLoc = NULL;
pWixLoc = static_cast<WIX_LOCALIZATION*>(MemAlloc(sizeof(WIX_LOCALIZATION), TRUE));
ExitOnNull(pWixLoc, hr, E_OUTOFMEMORY, "Failed to allocate memory for Wxl file.");
// read the WixLocalization tag
hr = pixd->get_documentElement(&pWxlElement);
ExitOnFailure(hr, "Failed to get localization element.");
// store the strings and controls in a node list
hr = ParseWxlStrings(pWxlElement, pWixLoc);
ExitOnFailure(hr, "Parsing localization strings failed.");
hr = ParseWxlControls(pWxlElement, pWixLoc);
ExitOnFailure(hr, "Parsing localization controls failed.");
*ppWixLoc = pWixLoc;
pWixLoc = NULL;
LExit:
ReleaseObject(pWxlElement);
ReleaseMem(pWixLoc);
return hr;
}
示例8: RegDefaultReadValueBinary
// Static functions
static HRESULT RegDefaultReadValueBinary(
__in CFGDB_STRUCT *pcdb,
__in HKEY hkKey,
__in_z LPCWSTR wzValueName,
__in_z LPCWSTR wzCfgValueName
)
{
HRESULT hr = S_OK;
BYTE *pbBuffer = NULL;
SIZE_T cbBuffer = 0;
CONFIG_VALUE cvNewValue = { };
hr = RegReadBinary(hkKey, wzValueName, &pbBuffer, &cbBuffer);
ExitOnFailure(hr, "Failed to read binary value from registry: %ls", wzValueName);
hr = ValueSetBlob(pbBuffer, cbBuffer, FALSE, NULL, pcdb->sczGuid, &cvNewValue);
ExitOnFailure(hr, "Failed to set string value %ls in memory", wzCfgValueName);
hr = ValueWrite(pcdb, pcdb->dwAppID, wzCfgValueName, &cvNewValue, TRUE, NULL);
ExitOnFailure(hr, "Failed to set value in db: %ls", wzCfgValueName);
LExit:
ReleaseMem(pbBuffer);
ReleaseCfgValue(cvNewValue);
return hr;
}
示例9: CreateDir
static int CreateDir(Directory *d)
{ char pathName[PATHNAMESIZE];
if (verbose)
printf("CreateDir called on directory '%s'\n", d->DirPathName);
if ( !FindUnusedDirName(d, pathName) )
{ if (verbose)
printf("CreateDir: FindUnusedDirName failed\n");
return 0;
}
printf("Creating directory %s\n", pathName);
if ( mkdir(pathName, S_IRWXU) == -1 )
{ printf("CreateDir: failed to create directory %s\n", pathName);
free(safetyBlock);
ReleaseMem();
return 0;
}
else
return 1;
}
示例10: CertGetAuthenticodeSigningTimestamp
extern "C" HRESULT DAPI CertGetAuthenticodeSigningTimestamp(
__in CMSG_SIGNER_INFO* pSignerInfo,
__out FILETIME* pftSigningTimestamp
)
{
HRESULT hr = S_OK;
CRYPT_INTEGER_BLOB* pBlob = NULL;
PCMSG_SIGNER_INFO pCounterSignerInfo = NULL;
DWORD cbSigningTimestamp = sizeof(FILETIME);
// Find the countersigner blob. The countersigner in Authenticode contains the time
// that signing took place. It's a "countersigner" because the signing time was sent
// off to the certificate authority in the sky to return the verified time signed.
for (DWORD i = 0; i < pSignerInfo->UnauthAttrs.cAttr; ++i)
{
if (CSTR_EQUAL == ::CompareStringA(LOCALE_NEUTRAL, 0, szOID_RSA_counterSign, -1, pSignerInfo->UnauthAttrs.rgAttr[i].pszObjId, -1))
{
pBlob = pSignerInfo->UnauthAttrs.rgAttr[i].rgValue;
break;
}
}
if (!pBlob)
{
hr = TRUST_E_FAIL;
ExitOnFailure(hr, "Failed to find countersigner in signer information.");
}
hr = CrypDecodeObject(PKCS7_SIGNER_INFO, pBlob->pbData, pBlob->cbData, 0, reinterpret_cast<LPVOID*>(&pCounterSignerInfo), NULL);
ExitOnFailure(hr, "Failed to decode countersigner information.");
pBlob = NULL; // reset the blob before searching for the signing time.
// Find the signing time blob in the countersigner.
for (DWORD i = 0; i < pCounterSignerInfo->AuthAttrs.cAttr; ++i)
{
if (CSTR_EQUAL == ::CompareStringA(LOCALE_NEUTRAL, 0, szOID_RSA_signingTime, -1, pCounterSignerInfo->AuthAttrs.rgAttr[i].pszObjId, -1))
{
pBlob = pCounterSignerInfo->AuthAttrs.rgAttr[i].rgValue;
break;
}
}
if (!pBlob)
{
hr = TRUST_E_FAIL;
ExitOnFailure(hr, "Failed to find signing time in countersigner information.");
}
if (!::CryptDecodeObject(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, szOID_RSA_signingTime, pBlob->pbData, pBlob->cbData, 0, pftSigningTimestamp, &cbSigningTimestamp))
{
ExitWithLastError(hr, "Failed to decode countersigner signing timestamp.");
}
LExit:
ReleaseMem(pCounterSignerInfo);
return hr;
}
示例11: DBGPRINTF
// ================================================================================
// FUNCTION : SetContactFromXml
// DESCRIPTION : Set contact from a xml.
// ================================================================================
bool CContactInfo::SetContactFromXml(char *pszXml, char *pszType)
{
DBGPRINTF(pszXml);
ReleaseMem();
char *pszFound=NULL;
//set type of contact
if ( 0==STRCMP("add", pszType))
m_nState = SM_RECORD_ADD;
else if ( 0==STRCMP("update", pszType))
m_nState = SM_RECORD_UPDATE;
else if ( 0==STRCMP("delete", pszType))
m_nState = SM_RECORD_DELETE;
else
return false;
int nLen=0;
char *pszEndTag=NULL;
char *pszNumber=NULL;
//set contact id
if ( !SetValue(&pszNumber, pszXml, "id")) return false;
if ( NULL!=pszNumber ) m_nContactId = (uint16)STRTOUL(pszNumber, NULL, 10);
DBGPRINTF("Contact id= %d", m_nContactId);
FREEIF(pszNumber);
//set global id
if ( !SetValue(&m_psGlobalId, pszXml, "gcid")) return false;
//set first name
if ( !SetValue(&m_psFName, pszXml, "fn")) return false;
if (NULL!=m_psFName) DBGPRINTF("%S", m_psFName);
if ( !SetValue(&m_psLName, pszXml, "ln")) return false;
if (NULL!=m_psLName) DBGPRINTF("%S", m_psLName);
if ( !SetValue(&m_psCompany, pszXml, "cn")) return false;
if (NULL!=m_psCompany) DBGPRINTF("%S", m_psCompany);
if ( !SetMultiValue(&m_psJTitle, pszXml, "ttls", "ttl")) return false;
if (NULL!=m_psJTitle) DBGPRINTF("%S", m_psJTitle);
if ( !SetMultiValue(&m_psFaxH, pszXml, "fxsh", "fxh")) return false;
if (NULL!=m_psFaxH) DBGPRINTF("%S", m_psFaxH);
if ( !SetMultiValue(&m_psFaxW, pszXml, "fxsw", "fxw")) return false;
if (NULL!=m_psFaxW) DBGPRINTF("%S", m_psFaxW);
if ( !SetMultiValue(&m_psFax, pszXml, "fxs", "fx")) return false;
if ( !SetMultiValue(&m_psMobileH, pszXml, "mblsh", "mblh")) return false;
if ( !SetMultiValue(&m_psMobileW, pszXml, "mblsb", "mblb")) return false;
if ( !SetMultiValue(&m_psMobile, pszXml, "mbls", "mbl")) return false;
if ( !SetMultiValue(&m_psTelephoneH, pszXml, "telsh", "telh")) return false;
if ( !SetMultiValue(&m_psTelephoneW, pszXml, "telsb", "telb")) return false;
if ( !SetMultiValue(&m_psTelephone, pszXml, "tels", "tel")) return false;
if ( !SetMultiValue(&m_psEmailW, pszXml, "emlsb", "emlb")) return false;
if ( !SetMultiValue(&m_psEmailH, pszXml, "emlsh", "emlh")) return false;
if ( !SetMultiValue(&m_psEmail, pszXml, "emls", "eml")) return false;
if (NULL!=m_psEmail) DBGPRINTF("%S", m_psEmail);
return true;
}
示例12: BeginChangeFile
static HRESULT BeginChangeFile(
__in LPCWSTR pwzFile,
__in int iCompAttributes,
__inout LPWSTR* ppwzCustomActionData
)
{
Assert(pwzFile && *pwzFile && ppwzCustomActionData);
HRESULT hr = S_OK;
BOOL fIs64Bit = iCompAttributes & msidbComponentAttributes64bit;
LPBYTE pbData = NULL;
DWORD cbData = 0;
LPWSTR pwzRollbackCustomActionData = NULL;
if (fIs64Bit)
{
hr = WcaWriteIntegerToCaData((int)xaOpenFilex64, ppwzCustomActionData);
ExitOnFailure(hr, "failed to write 64-bit file indicator to custom action data");
}
else
{
hr = WcaWriteIntegerToCaData((int)xaOpenFile, ppwzCustomActionData);
ExitOnFailure(hr, "failed to write file indicator to custom action data");
}
hr = WcaWriteStringToCaData(pwzFile, ppwzCustomActionData);
ExitOnFailure1(hr, "failed to write file to custom action data: %ls", pwzFile);
// If the file already exits, then we have to put it back the way it was on failure
if (FileExistsEx(pwzFile, NULL))
{
hr = FileRead(&pbData, &cbData, pwzFile);
ExitOnFailure1(hr, "failed to read file: %ls", pwzFile);
// Set up the rollback for this file
hr = WcaWriteIntegerToCaData((int)fIs64Bit, &pwzRollbackCustomActionData);
ExitOnFailure(hr, "failed to write component bitness to rollback custom action data");
hr = WcaWriteStringToCaData(pwzFile, &pwzRollbackCustomActionData);
ExitOnFailure1(hr, "failed to write file name to rollback custom action data: %ls", pwzFile);
hr = WcaWriteStreamToCaData(pbData, cbData, &pwzRollbackCustomActionData);
ExitOnFailure(hr, "failed to write file contents to rollback custom action data.");
hr = WcaDoDeferredAction(PLATFORM_DECORATION(L"ExecXmlConfigRollback"), pwzRollbackCustomActionData, COST_XMLFILE);
ExitOnFailure1(hr, "failed to schedule ExecXmlConfigRollback for file: %ls", pwzFile);
ReleaseStr(pwzRollbackCustomActionData);
}
LExit:
ReleaseMem(pbData);
return hr;
}
示例13: DAPI_
DAPI_(void) JsonUninitializeWriter(
__in JSON_WRITER* pWriter
)
{
ReleaseMem(pWriter->rgTokenStack);
ReleaseStr(pWriter->sczJson);
::DeleteCriticalSection(&pWriter->cs);
memset(pWriter, 0, sizeof(JSON_WRITER));
}
示例14: EnsureWUServiceEnabled
static HRESULT EnsureWUServiceEnabled(
__in BOOL fStopWusaService,
__out SC_HANDLE* pschWu,
__out BOOL* pfPreviouslyDisabled
)
{
HRESULT hr = S_OK;
SC_HANDLE schSCM = NULL;
SC_HANDLE schWu = NULL;
SERVICE_STATUS serviceStatus = { };
QUERY_SERVICE_CONFIGW* pConfig = NULL;
schSCM = ::OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS);
ExitOnNullWithLastError(schSCM, hr, "Failed to open service control manager.");
schWu = ::OpenServiceW(schSCM, L"wuauserv", SERVICE_QUERY_CONFIG | SERVICE_CHANGE_CONFIG | SERVICE_QUERY_STATUS | SERVICE_STOP );
ExitOnNullWithLastError(schWu, hr, "Failed to open WU service.");
if (!::QueryServiceStatus(schWu, &serviceStatus) )
{
ExitWithLastError(hr, "Failed to query status of WU service.");
}
// Stop service if requested to.
if (SERVICE_STOPPED != serviceStatus.dwCurrentState && fStopWusaService)
{
hr = StopWUService(schWu);
}
// If the service is not running then it might be disabled so let's check.
if (SERVICE_RUNNING != serviceStatus.dwCurrentState)
{
hr = SvcQueryConfig(schWu, &pConfig);
ExitOnFailure(hr, "Failed to read configuration for WU service.");
// If WU is disabled, change it to a demand start service (but touch nothing else).
if (SERVICE_DISABLED == pConfig->dwStartType)
{
hr = SetServiceStartType(schWu, SERVICE_DEMAND_START);
ExitOnFailure(hr, "Failed to mark WU service to start on demand.");
*pfPreviouslyDisabled = TRUE;
}
}
*pschWu = schWu;
schWu = NULL;
LExit:
ReleaseMem(pConfig);
ReleaseServiceHandle(schWu);
ReleaseServiceHandle(schSCM);
return hr;
}
示例15: DAPI_
DAPI_(void) BalConditionsUninitialize(
__in BAL_CONDITIONS* pConditions
)
{
for (DWORD i = 0; i < pConditions->cConditions; ++i)
{
ReleaseStr(pConditions->rgConditions[i].sczMessage);
ReleaseStr(pConditions->rgConditions[i].sczCondition);
}
ReleaseMem(pConditions->rgConditions);
memset(pConditions, 0, sizeof(BAL_CONDITIONS));
}