本文整理汇总了C++中RTStrFree函数的典型用法代码示例。如果您正苦于以下问题:C++ RTStrFree函数的具体用法?C++ RTStrFree怎么用?C++ RTStrFree使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RTStrFree函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RTDECL
RTDECL(int) RTGetOptArgvToUtf16String(PRTUTF16 *ppwszCmdLine, const char * const *papszArgv, uint32_t fFlags)
{
char *pszCmdLine;
int rc = RTGetOptArgvToString(&pszCmdLine, papszArgv, fFlags);
if (RT_SUCCESS(rc))
{
rc = RTStrToUtf16(pszCmdLine, ppwszCmdLine);
RTStrFree(pszCmdLine);
}
return rc;
}
示例2: RTDECL
RTDECL(int) RTEnvDestroy(RTENV Env)
{
/*
* Ignore NIL_RTENV and validate input.
*/
if ( Env == NIL_RTENV
|| Env == RTENV_DEFAULT)
return VINF_SUCCESS;
PRTENVINTERNAL pIntEnv = Env;
AssertPtrReturn(pIntEnv, VERR_INVALID_HANDLE);
AssertReturn(pIntEnv->u32Magic == RTENV_MAGIC, VERR_INVALID_HANDLE);
/*
* Do the cleanup.
*/
RTENV_LOCK(pIntEnv);
pIntEnv->u32Magic++;
size_t iVar = pIntEnv->cVars;
while (iVar-- > 0)
RTStrFree(pIntEnv->papszEnv[iVar]);
RTMemFree(pIntEnv->papszEnv);
pIntEnv->papszEnv = NULL;
if (pIntEnv->papszEnvOtherCP)
{
for (iVar = 0; pIntEnv->papszEnvOtherCP[iVar]; iVar++)
{
RTStrFree(pIntEnv->papszEnvOtherCP[iVar]);
pIntEnv->papszEnvOtherCP[iVar] = NULL;
}
RTMemFree(pIntEnv->papszEnvOtherCP);
pIntEnv->papszEnvOtherCP = NULL;
}
RTENV_UNLOCK(pIntEnv);
/*RTCritSectDelete(&pIntEnv->CritSect) */
RTMemFree(pIntEnv);
return VINF_SUCCESS;
}
示例3: rewrite_SvnKeywords
/**
* Make sure the Id and Revision keywords are expanded.
*
* @returns false - the state carries these kinds of changes.
* @param pState The rewriter state.
* @param pIn The input stream.
* @param pOut The output stream.
* @param pSettings The settings.
*/
bool rewrite_SvnKeywords(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings)
{
if ( !pSettings->fSetSvnKeywords
|| !ScmSvnIsInWorkingCopy(pState))
return false;
char *pszKeywords;
int rc = ScmSvnQueryProperty(pState, "svn:keywords", &pszKeywords);
if ( RT_SUCCESS(rc)
&& ( !strstr(pszKeywords, "Id") /** @todo need some function for finding a word in a string. */
|| !strstr(pszKeywords, "Revision")) )
{
if (!strstr(pszKeywords, "Id") && !strstr(pszKeywords, "Revision"))
rc = RTStrAAppend(&pszKeywords, " Id Revision");
else if (!strstr(pszKeywords, "Id"))
rc = RTStrAAppend(&pszKeywords, " Id");
else
rc = RTStrAAppend(&pszKeywords, " Revision");
if (RT_SUCCESS(rc))
{
ScmVerbose(pState, 2, " * changing svn:keywords to '%s'\n", pszKeywords);
rc = ScmSvnSetProperty(pState, "svn:keywords", pszKeywords);
if (RT_FAILURE(rc))
RTMsgError("ScmSvnSetProperty: %Rrc\n", rc); /** @todo error propagation here.. */
}
else
RTMsgError("RTStrAppend: %Rrc\n", rc); /** @todo error propagation here.. */
RTStrFree(pszKeywords);
}
else if (rc == VERR_NOT_FOUND)
{
ScmVerbose(pState, 2, " * setting svn:keywords to 'Id Revision'\n");
rc = ScmSvnSetProperty(pState, "svn:keywords", "Id Revision");
if (RT_FAILURE(rc))
RTMsgError("ScmSvnSetProperty: %Rrc\n", rc); /** @todo error propagation here.. */
}
else if (RT_SUCCESS(rc))
RTStrFree(pszKeywords);
return false;
}
示例4: RTDECL
RTDECL(int) RTEnvUnsetEx(RTENV Env, const char *pszVar)
{
AssertPtrReturn(pszVar, VERR_INVALID_POINTER);
AssertReturn(*pszVar, VERR_INVALID_PARAMETER);
int rc;
if (Env == RTENV_DEFAULT)
{
/*
* Since RTEnvUnset isn't UTF-8 clean and actually expects the strings
* to be in the current code page (codeset), we'll do the necessary
* conversions here.
*/
char *pszVarOtherCP;
rc = RTStrUtf8ToCurrentCP(&pszVarOtherCP, pszVar);
if (RT_SUCCESS(rc))
{
rc = RTEnvUnset(pszVarOtherCP);
RTStrFree(pszVarOtherCP);
}
}
else
{
PRTENVINTERNAL pIntEnv = Env;
AssertPtrReturn(pIntEnv, VERR_INVALID_HANDLE);
AssertReturn(pIntEnv->u32Magic == RTENV_MAGIC, VERR_INVALID_HANDLE);
RTENV_LOCK(pIntEnv);
/*
* Remove all variable by the given name.
*/
rc = VINF_ENV_VAR_NOT_FOUND;
const size_t cchVar = strlen(pszVar);
size_t iVar;
for (iVar = 0; iVar < pIntEnv->cVars; iVar++)
if ( !strncmp(pIntEnv->papszEnv[iVar], pszVar, cchVar)
&& pIntEnv->papszEnv[iVar][cchVar] == '=')
{
RTMemFree(pIntEnv->papszEnv[iVar]);
pIntEnv->cVars--;
if (pIntEnv->cVars > 0)
pIntEnv->papszEnv[iVar] = pIntEnv->papszEnv[pIntEnv->cVars];
pIntEnv->papszEnv[pIntEnv->cVars] = NULL;
rc = VINF_SUCCESS;
/* no break, there could be more. */
}
RTENV_UNLOCK(pIntEnv);
}
return rc;
}
示例5: RTDECL
RTDECL(int) RTSymlinkRead(const char *pszSymlink, char *pszTarget, size_t cbTarget, uint32_t fRead)
{
char *pszMyTarget;
int rc = RTSymlinkReadA(pszSymlink, &pszMyTarget);
if (RT_SUCCESS(rc))
{
rc = RTStrCopy(pszTarget, cbTarget, pszMyTarget);
RTStrFree(pszMyTarget);
}
LogFlow(("RTSymlinkRead(%p={%s}): returns %Rrc\n", pszSymlink, pszSymlink, rc));
return rc;
}
示例6: IsTestcaseIncluded
/**
* Checks if a testcase is include or should be skipped.
*
* @param pszTestcase The testcase (filename).
*
* @return true if the testcase is included.
* false if the testcase should be skipped.
*/
static bool IsTestcaseIncluded(const char *pszTestcase)
{
/* exclude special modules based on extension. */
const char *pszExt = RTPathExt(pszTestcase);
if ( !RTStrICmp(pszExt, ".r0")
|| !RTStrICmp(pszExt, ".gc")
|| !RTStrICmp(pszExt, ".sys")
|| !RTStrICmp(pszExt, ".ko")
|| !RTStrICmp(pszExt, ".o")
|| !RTStrICmp(pszExt, ".obj")
|| !RTStrICmp(pszExt, ".lib")
|| !RTStrICmp(pszExt, ".a")
|| !RTStrICmp(pszExt, ".so")
|| !RTStrICmp(pszExt, ".dll")
|| !RTStrICmp(pszExt, ".dylib")
|| !RTStrICmp(pszExt, ".tmp")
|| !RTStrICmp(pszExt, ".log")
)
return false;
/* check by name */
char *pszDup = RTStrDup(pszTestcase);
if (pszDup)
{
RTPathStripExt(pszDup);
for (unsigned i = 0; i < RT_ELEMENTS(g_apszExclude); i++)
{
if (!strcmp(g_apszExclude[i], pszDup))
{
RTStrFree(pszDup);
return false;
}
}
RTStrFree(pszDup);
return true;
}
RTPrintf("tstRunTestcases: Out of memory!\n");
return false;
}
示例7: vbglR3GetAdditionsCompileTimeVersion
/**
* Fallback for VbglR3GetAdditionsVersion.
*/
static int vbglR3GetAdditionsCompileTimeVersion(char **ppszVer, char **ppszVerEx, char **ppszRev)
{
int rc = VINF_SUCCESS;
if (ppszVer)
rc = RTStrDupEx(ppszVer, VBOX_VERSION_STRING_RAW);
if (RT_SUCCESS(rc))
{
if (ppszVerEx)
rc = RTStrDupEx(ppszVerEx, VBOX_VERSION_STRING);
if (RT_SUCCESS(rc))
{
if (ppszRev)
{
#if 0
char szRev[64];
RTStrPrintf(szRev, sizeof(szRev), "%d", VBOX_SVN_REV);
rc = RTStrDupEx(ppszRev, szRev);
#else
rc = RTStrDupEx(ppszRev, RT_XSTR(VBOX_SVN_REV));
#endif
}
if (RT_SUCCESS(rc))
return VINF_SUCCESS;
/* bail out: */
}
if (ppszVerEx)
{
RTStrFree(*ppszVerEx);
*ppszVerEx = NULL;
}
}
if (ppszVer)
{
RTStrFree(*ppszVer);
*ppszVer = NULL;
}
return rc;
}
示例8: RTR3DECL
RTR3DECL(int) RTHttpSetCAFile(RTHTTP hHttp, const char *pcszCAFile)
{
PRTHTTPINTERNAL pHttpInt = hHttp;
RTHTTP_VALID_RETURN(pHttpInt);
if (pHttpInt->pcszCAFile)
RTStrFree(pHttpInt->pcszCAFile);
pHttpInt->pcszCAFile = RTStrDup(pcszCAFile);
if (!pHttpInt->pcszCAFile)
return VERR_NO_MEMORY;
return VINF_SUCCESS;
}
示例9: RTR3DECL
RTR3DECL(void) RTS3Destroy(RTS3 hS3)
{
if (hS3 == NIL_RTS3)
return;
PRTS3INTERNAL pS3Int = hS3;
RTS3_VALID_RETURN_VOID(pS3Int);
curl_easy_cleanup(pS3Int->pCurl);
pS3Int->u32Magic = RTS3_MAGIC_DEAD;
if (pS3Int->pszUserAgent)
RTStrFree(pS3Int->pszUserAgent);
RTStrFree(pS3Int->pszBaseUrl);
RTStrFree(pS3Int->pszSecretKey);
RTStrFree(pS3Int->pszAccessKey);
RTMemFree(pS3Int);
curl_global_cleanup();
}
示例10: rtS3CreateAuthHeader
static char* rtS3CreateAuthHeader(PRTS3INTERNAL pS3Int, const char* pszAction, const char* pszBucket, const char* pszKey,
char** papszHeadEnts, size_t cHeadEnts)
{
char *pszAuth;
/* Create a signature out of the header & the bucket/key info */
char *pszSigBase64Enc = rtS3CreateSignature(pS3Int, pszAction, pszBucket, pszKey, papszHeadEnts, cHeadEnts);
/* Create the authorization header entry */
RTStrAPrintf(&pszAuth, "Authorization: AWS %s:%s",
pS3Int->pszAccessKey,
pszSigBase64Enc);
RTStrFree(pszSigBase64Enc);
return pszAuth;
}
示例11: ScmStreamPrintfV
/**
* Formats a string and writes it to the SCM stream.
*
* @returns The number of bytes written (>= 0). Negative value are IPRT error
* status codes.
* @param pStream The stream to write to.
* @param pszFormat The format string.
* @param va The arguments to format.
*/
ssize_t ScmStreamPrintfV(PSCMSTREAM pStream, const char *pszFormat, va_list va)
{
char *psz;
ssize_t cch = RTStrAPrintfV(&psz, pszFormat, va);
if (cch)
{
int rc = ScmStreamWrite(pStream, psz, cch);
RTStrFree(psz);
if (RT_FAILURE(rc))
cch = rc;
}
return cch;
}
示例12: VBoxServiceReadHostProp
/**
* Reads a guest property from the host side.
*
* @returns VBox status code, fully bitched.
*
* @param u32ClientId The HGCM client ID for the guest property session.
* @param pszPropName The property name.
* @param fReadOnly Whether or not this property needs to be read only
* by the guest side. Otherwise VERR_ACCESS_DENIED will
* be returned.
* @param ppszValue Where to return the value. This is always set
* to NULL. Free it using RTStrFree().
* @param ppszFlags Where to return the value flags. Free it
* using RTStrFree(). Optional.
* @param puTimestamp Where to return the timestamp. This is only set
* on success. Optional.
*/
int VBoxServiceReadHostProp(uint32_t u32ClientId, const char *pszPropName, bool fReadOnly,
char **ppszValue, char **ppszFlags, uint64_t *puTimestamp)
{
AssertPtrReturn(ppszValue, VERR_INVALID_PARAMETER);
char *pszValue = NULL;
char *pszFlags = NULL;
int rc = VBoxServiceReadProp(u32ClientId, pszPropName, &pszValue, &pszFlags, puTimestamp);
if (RT_SUCCESS(rc))
{
/* Check security bits. */
if ( fReadOnly /* Do we except a guest read-only property */
&& !RTStrStr(pszFlags, "RDONLYGUEST"))
{
/* If we want a property which is read-only on the guest
* and it is *not* marked as such, deny access! */
rc = VERR_ACCESS_DENIED;
}
if (RT_SUCCESS(rc))
{
*ppszValue = pszValue;
if (ppszFlags)
*ppszFlags = pszFlags;
else if (pszFlags)
RTStrFree(pszFlags);
}
else
{
if (pszValue)
RTStrFree(pszValue);
if (pszFlags)
RTStrFree(pszFlags);
}
}
return rc;
}
示例13: dbgfR3AsSearchEnvPath
/**
* Same as dbgfR3AsSearchEnv, except that the path is taken from the environment.
*
* If the environment variable doesn't exist, the current directory is searched
* instead.
*
* @returns VBox status code.
* @param pszFilename The filename.
* @param pszEnvVar The environment variable name.
* @param pfnOpen The open callback function.
* @param pvUser User argument for the callback.
*/
static int dbgfR3AsSearchEnvPath(const char *pszFilename, const char *pszEnvVar, PFNDBGFR3ASSEARCHOPEN pfnOpen, void *pvUser)
{
int rc;
char *pszPath = RTEnvDupEx(RTENV_DEFAULT, pszEnvVar);
if (pszPath)
{
rc = dbgfR3AsSearchPath(pszFilename, pszPath, pfnOpen, pvUser);
RTStrFree(pszPath);
}
else
rc = dbgfR3AsSearchPath(pszFilename, ".", pfnOpen, pvUser);
return rc;
}
示例14: pdmR3CritSectDeleteOne
/**
* Deletes one critical section.
*
* @returns Return code from RTCritSectDelete.
*
* @param pVM Pointer to the VM.
* @param pCritSect The critical section.
* @param pPrev The previous critical section in the list.
* @param fFinal Set if this is the final call and statistics shouldn't be deregistered.
*
* @remarks Caller must have entered the ListCritSect.
*/
static int pdmR3CritSectDeleteOne(PVM pVM, PUVM pUVM, PPDMCRITSECTINT pCritSect, PPDMCRITSECTINT pPrev, bool fFinal)
{
/*
* Assert free waiters and so on (c&p from RTCritSectDelete).
*/
Assert(pCritSect->Core.u32Magic == RTCRITSECT_MAGIC);
Assert(pCritSect->Core.cNestings == 0);
Assert(pCritSect->Core.cLockers == -1);
Assert(pCritSect->Core.NativeThreadOwner == NIL_RTNATIVETHREAD);
Assert(RTCritSectIsOwner(&pUVM->pdm.s.ListCritSect));
/*
* Unlink it.
*/
if (pPrev)
pPrev->pNext = pCritSect->pNext;
else
pUVM->pdm.s.pCritSects = pCritSect->pNext;
/*
* Delete it (parts taken from RTCritSectDelete).
* In case someone is waiting we'll signal the semaphore cLockers + 1 times.
*/
ASMAtomicWriteU32(&pCritSect->Core.u32Magic, 0);
SUPSEMEVENT hEvent = (SUPSEMEVENT)pCritSect->Core.EventSem;
pCritSect->Core.EventSem = NIL_RTSEMEVENT;
while (pCritSect->Core.cLockers-- >= 0)
SUPSemEventSignal(pVM->pSession, hEvent);
ASMAtomicWriteS32(&pCritSect->Core.cLockers, -1);
int rc = SUPSemEventClose(pVM->pSession, hEvent);
AssertRC(rc);
RTLockValidatorRecExclDestroy(&pCritSect->Core.pValidatorRec);
pCritSect->pNext = NULL;
pCritSect->pvKey = NULL;
pCritSect->pVMR3 = NULL;
pCritSect->pVMR0 = NIL_RTR0PTR;
pCritSect->pVMRC = NIL_RTRCPTR;
RTStrFree((char *)pCritSect->pszName);
pCritSect->pszName = NULL;
if (!fFinal)
{
STAMR3Deregister(pVM, &pCritSect->StatContentionRZLock);
STAMR3Deregister(pVM, &pCritSect->StatContentionRZUnlock);
STAMR3Deregister(pVM, &pCritSect->StatContentionR3);
#ifdef VBOX_WITH_STATISTICS
STAMR3Deregister(pVM, &pCritSect->StatLocked);
#endif
}
return rc;
}
示例15: pam_vbox_error
/**
* Displays an error message.
*
* @param hPAM PAM handle.
* @param pszFormat The message text.
* @param ... Format arguments.
*/
static void pam_vbox_error(pam_handle_t *hPAM, const char *pszFormat, ...)
{
RT_NOREF1(hPAM);
va_list va;
char *buf;
va_start(va, pszFormat);
if (RT_SUCCESS(RTStrAPrintfV(&buf, pszFormat, va)))
{
LogRel(("%s: Error: %s", VBOX_MODULE_NAME, buf));
pam_vbox_writesyslog(buf);
RTStrFree(buf);
}
va_end(va);
}