本文整理汇总了C++中PR_FREEIF函数的典型用法代码示例。如果您正苦于以下问题:C++ PR_FREEIF函数的具体用法?C++ PR_FREEIF怎么用?C++ PR_FREEIF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PR_FREEIF函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MimeInlineText_parse_end
static int
MimeInlineText_parse_end (MimeObject *obj, bool abort_p)
{
MimeInlineText *text = (MimeInlineText *) obj;
if (obj->parsed_p)
{
PR_ASSERT(obj->closed_p);
return 0;
}
/* We won't be needing this buffer any more; nuke it. */
PR_FREEIF(text->cbuffer);
text->cbuffer_size = 0;
return ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_end (obj, abort_p);
}
示例2: ap_encode_end
int ap_encode_end(
appledouble_encode_object *p_ap_encode_obj,
bool is_aborting)
{
/*
** clear up the apple doubler.
*/
if (p_ap_encode_obj == NULL)
return noErr;
if (p_ap_encode_obj->fileId) /* close the file if it is open. */
::FSCloseFork(p_ap_encode_obj->fileId);
PR_FREEIF(p_ap_encode_obj->boundary); /* the boundary string. */
return noErr;
}
示例3: PR_FREEIF
NS_IMETHODIMP
nsFileInputStream::Seek(PRInt32 aWhence, PRInt64 aOffset)
{
PR_FREEIF(mLineBuffer); // this invalidates the line buffer
if (!mFD) {
if (mBehaviorFlags & REOPEN_ON_REWIND) {
nsresult rv = Reopen();
if (NS_FAILED(rv)) {
return rv;
}
} else {
return NS_BASE_STREAM_CLOSED;
}
}
return nsFileStream::Seek(aWhence, aOffset);
}
示例4: MimeHeaders_copy
MimeHeaders *
MimeHeaders_copy (MimeHeaders *hdrs)
{
MimeHeaders *hdrs2;
if (!hdrs) return 0;
hdrs2 = (MimeHeaders *) PR_MALLOC(sizeof(*hdrs));
if (!hdrs2) return 0;
memset(hdrs2, 0, sizeof(*hdrs2));
if (hdrs->all_headers)
{
hdrs2->all_headers = (char *) PR_MALLOC(hdrs->all_headers_fp);
if (!hdrs2->all_headers)
{
PR_Free(hdrs2);
return 0;
}
memcpy(hdrs2->all_headers, hdrs->all_headers, hdrs->all_headers_fp);
hdrs2->all_headers_fp = hdrs->all_headers_fp;
hdrs2->all_headers_size = hdrs->all_headers_fp;
}
hdrs2->done_p = hdrs->done_p;
if (hdrs->heads)
{
int i;
hdrs2->heads = (char **) PR_MALLOC(hdrs->heads_size
* sizeof(*hdrs->heads));
if (!hdrs2->heads)
{
PR_FREEIF(hdrs2->all_headers);
PR_Free(hdrs2);
return 0;
}
hdrs2->heads_size = hdrs->heads_size;
for (i = 0; i < hdrs->heads_size; i++)
{
hdrs2->heads[i] = (hdrs2->all_headers +
(hdrs->heads[i] - hdrs->all_headers));
}
}
return hdrs2;
}
示例5: DIR_SetServerFileName
void DIR_SetServerFileName(DIR_Server *server)
{
char * tempName = nsnull;
const char * prefName = nsnull;
PRUint32 numHeaderBytes = 0;
if (server && (!server->fileName || !(*server->fileName)) )
{
PR_FREEIF(server->fileName); // might be one byte empty string.
/* make sure we have a pref name...*/
if (!server->prefName || !*server->prefName)
server->prefName = dir_CreateServerPrefName(server);
/* set default personal address book file name*/
if ((server->position == 1) && (server->dirType == PABDirectory))
server->fileName = strdup(kPersonalAddressbook);
else
{
/* now use the pref name as the file name since we know the pref name
will be unique */
prefName = server->prefName;
if (prefName && *prefName)
{
/* extract just the pref name part and not the ldap tree name portion from the string */
numHeaderBytes = PL_strlen(PREF_LDAP_SERVER_TREE_NAME) + 1; /* + 1 for the '.' b4 the name */
if (PL_strlen(prefName) > numHeaderBytes)
tempName = strdup(prefName + numHeaderBytes);
if (tempName)
{
server->fileName = PR_smprintf("%s%s", tempName, kABFileName_CurrentSuffix);
PR_Free(tempName);
}
}
}
if (!server->fileName || !*server->fileName) /* when all else has failed, generate a default name */
{
if (server->dirType == LDAPDirectory)
DIR_SetFileName(&(server->fileName), kMainLdapAddressBook); /* generates file name with an ldap prefix */
else
DIR_SetFileName(&(server->fileName), kPersonalAddressbook);
}
}
}
示例6: NS_ENSURE_TRUE
NS_IMETHODIMP nsCollationMacUC::AllocateRawSortKey(int32_t strength, const nsAString& stringIn,
uint8_t** key, uint32_t* outLen)
{
NS_ENSURE_TRUE(mInit, NS_ERROR_NOT_INITIALIZED);
NS_ENSURE_ARG_POINTER(key);
NS_ENSURE_ARG_POINTER(outLen);
nsresult res = EnsureCollator(strength);
NS_ENSURE_SUCCESS(res, res);
uint32_t stringInLen = stringIn.Length();
uint32_t maxKeyLen = (1 + stringInLen) * kCollationValueSizeFactor * sizeof(UCCollationValue);
if (maxKeyLen > mBufferLen) {
uint32_t newBufferLen = mBufferLen;
do {
newBufferLen *= 2;
} while (newBufferLen < maxKeyLen);
void *newBuffer = PR_Malloc(newBufferLen);
if (!newBuffer)
return NS_ERROR_OUT_OF_MEMORY;
PR_FREEIF(mBuffer);
mBuffer = newBuffer;
mBufferLen = newBufferLen;
}
ItemCount actual;
OSStatus err = ::UCGetCollationKey(mCollator, (const UniChar*) PromiseFlatString(stringIn).get(),
(UniCharCount) stringInLen,
(ItemCount) (mBufferLen / sizeof(UCCollationValue)),
&actual, (UCCollationValue *)mBuffer);
NS_ENSURE_TRUE((err == noErr), NS_ERROR_FAILURE);
uint32_t keyLength = actual * sizeof(UCCollationValue);
void *newKey = PR_Malloc(keyLength);
if (!newKey)
return NS_ERROR_OUT_OF_MEMORY;
memcpy(newKey, mBuffer, keyLength);
*key = (uint8_t *)newKey;
*outLen = keyLength;
return NS_OK;
}
示例7: escape_for_mrel_subst
/* This routine is only necessary because the mailbox URL fed to us
by the winfe can contain spaces and '>'s in it. It's a hack. */
static char *
escape_for_mrel_subst(char *inURL)
{
char *output, *inC, *outC, *temp;
int size = strlen(inURL) + 1;
for(inC = inURL; *inC; inC++)
if ((*inC == ' ') || (*inC == '>'))
size += 2; /* space -> '%20', '>' -> '%3E', etc. */
output = (char *)PR_MALLOC(size);
if (output)
{
/* Walk through the source string, copying all chars
except for spaces, which get escaped. */
inC = inURL;
outC = output;
while(*inC)
{
if (*inC == ' ')
{
*outC++ = '%'; *outC++ = '2'; *outC++ = '0';
}
else if (*inC == '>')
{
*outC++ = '%'; *outC++ = '3'; *outC++ = 'E';
}
else
*outC++ = *inC;
inC++;
}
*outC = '\0';
temp = escape_unescaped_percents(output);
if (temp)
{
PR_FREEIF(output);
output = temp;
}
}
return output;
}
示例8: MimeMultipartAlternative_display_part_p
static bool
MimeMultipartAlternative_display_part_p(MimeObject *self,
MimeHeaders *sub_hdrs)
{
char *ct = MimeHeaders_get (sub_hdrs, HEADER_CONTENT_TYPE, true, false);
if (!ct)
return false;
/* RFC 1521 says:
Receiving user agents should pick and display the last format
they are capable of displaying. In the case where one of the
alternatives is itself of type "multipart" and contains unrecognized
sub-parts, the user agent may choose either to show that alternative,
an earlier alternative, or both.
Ugh. If there is a multipart subtype of alternative, we simply show
that, without descending into it to determine if any of its sub-parts
are themselves unknown.
*/
// prefer_plaintext pref
nsIPrefBranch *prefBranch = GetPrefBranch(self->options);
bool prefer_plaintext = false;
if (prefBranch)
prefBranch->GetBoolPref("mailnews.display.prefer_plaintext",
&prefer_plaintext);
if (prefer_plaintext
&& self->options->format_out != nsMimeOutput::nsMimeMessageSaveAs
&& (!PL_strncasecmp(ct, "text/html", 9) ||
!PL_strncasecmp(ct, "text/enriched", 13) ||
!PL_strncasecmp(ct, "text/richtext", 13))
)
// if the user prefers plaintext and this is the "rich" (e.g. HTML) part...
{
return false;
}
MimeObjectClass *clazz = mime_find_class (ct, sub_hdrs, self->options, true);
bool result = (clazz
? clazz->displayable_inline_p(clazz, sub_hdrs)
: false);
PR_FREEIF(ct);
return result;
}
示例9: getPRErrorText
/* static */
void WebCL_LibCL::unload (WebCL_LibCL* aInstance)
{
D_METHOD_START;
if (!(aInstance && aInstance->m_libHandle))
return;
if (PR_UnloadLibrary (aInstance->m_libHandle) == PR_FAILURE)
{
char *errText = getPRErrorText ();
D_LOG (LOG_LEVEL_WARNING, "Failed to unload library %s: %s", aInstance->m_libName, errText);
D_LOG (LOG_LEVEL_DEBUG, " (prerr: %d oserr: %d)", PR_GetError(), PR_GetOSError());
PR_FREEIF (errText);
}
else
{
D_LOG (LOG_LEVEL_DEBUG, "Unloaded library %s", aInstance->m_libName);
}
}
示例10: SetOtherHeaders
int nsMsgSendPart::AppendOtherHeaders(const char* more)
{
if (!m_other)
return SetOtherHeaders(more);
if (!more || !*more)
return 0;
char* tmp = (char *) PR_Malloc(sizeof(char) * (PL_strlen(m_other) + PL_strlen(more) + 2));
if (!tmp)
return NS_ERROR_OUT_OF_MEMORY;
PL_strcpy(tmp, m_other);
PL_strcat(tmp, more);
PR_FREEIF(m_other);
m_other = tmp;
return 0;
}
示例11: appendcOFile_
static void appendcOFile_(OFile *fp, char c)
{
if (fp->fail)
return;
stuff:
if (fp->len+1 < fp->limit) {
fp->s[fp->len] = c;
fp->len++;
return;
}
else if (fp->alloc) {
fp->limit = fp->limit + OFILE_REALLOC_SIZE;
fp->s = (char *)PR_Realloc(fp->s,fp->limit);
if (fp->s) goto stuff;
}
if (fp->alloc)
PR_FREEIF(fp->s);
fp->s = 0;
fp->fail = 1;
}
示例12: PR_FREEIF
/* void onDataAvailable (in nsIRequest request, in nsISupports ctxt, in nsIInputStream inStr, in unsigned long long sourceOffset, in unsigned long count); */
NS_IMETHODIMP nsURLFetcherStreamConsumer::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctxt, nsIInputStream *inStr, uint64_t sourceOffset, uint32_t count)
{
uint32_t readLen = count;
uint32_t wroteIt;
if (!mURLFetcher)
return NS_ERROR_FAILURE;
if (!mURLFetcher->mOutStream)
return NS_ERROR_INVALID_ARG;
if (mURLFetcher->mBufferSize < count)
{
PR_FREEIF(mURLFetcher->mBuffer);
if (count > 0x1000)
mURLFetcher->mBufferSize = count;
else
mURLFetcher->mBufferSize = 0x1000;
mURLFetcher->mBuffer = (char *)PR_Malloc(mURLFetcher->mBufferSize);
if (!mURLFetcher->mBuffer)
return NS_ERROR_OUT_OF_MEMORY; /* we couldn't allocate the object */
}
// read the data from the input stram...
nsresult rv = inStr->Read(mURLFetcher->mBuffer, count, &readLen);
if (NS_FAILED(rv))
return rv;
// write to the output file...
mURLFetcher->mOutStream->Write(mURLFetcher->mBuffer, readLen, &wroteIt);
if (wroteIt != readLen)
return NS_ERROR_FAILURE;
else
{
mURLFetcher->mTotalWritten += wroteIt;
return NS_OK;
}
}
示例13: nsIMAPBodypart
nsIMAPBodypartMultipart::nsIMAPBodypartMultipart(char *partNum, nsIMAPBodypart *parentPart) :
nsIMAPBodypart(partNum, parentPart)
{
if (!m_parentPart || (m_parentPart->GetType() == IMAP_BODY_MESSAGE_RFC822))
{
// the multipart (this) will inherit the part number of its parent
PR_FREEIF(m_partNumberString);
if (!m_parentPart)
{
m_partNumberString = PR_smprintf("0");
}
else
m_partNumberString = NS_strdup(m_parentPart->GetPartNumberString());
}
m_partList = new nsVoidArray();
m_bodyType = NS_strdup("multipart");
if (m_partList && m_parentPart && m_bodyType)
SetIsValid(true);
else
SetIsValid(false);
}
示例14: MIME_EncoderDestroy
nsMsgComposeSecure::~nsMsgComposeSecure()
{
/* destructor code */
if (mEncryptionContext) {
if (mBufferedBytes) {
mEncryptionContext->Update(mBuffer, mBufferedBytes);
mBufferedBytes = 0;
}
mEncryptionContext->Finish();
}
if (mSigEncoderData) {
MIME_EncoderDestroy (mSigEncoderData, true);
}
if (mCryptoEncoderData) {
MIME_EncoderDestroy (mCryptoEncoderData, true);
}
delete [] mBuffer;
PR_FREEIF(mMultipartSignedBoundary);
}
示例15: FilterWithoutEnglishLetters
ProbingState SBCSGroupProber::HandleData(const char* aBuf, PRUint32 aLen)
{
ProbingState st;
PRUint32 i;
char *newBuf1;
PRUint32 newLen1;
//apply filter to original buffer, and we got new buffer back
//depend on what script it is, we will feed them the new buffer
//we got after applying proper filter
FilterWithoutEnglishLetters(aBuf, aLen, &newBuf1, newLen1);
for (i = 0; i < NUM_OF_SBCS_PROBERS; i++)
{
if (!mIsActive[i])
continue;
st = mProbers[i]->HandleData(newBuf1, newLen1);
if (st == eFoundIt)
{
mBestGuess = i;
mState = eFoundIt;
break;
}
else if (st == eNotMe)
{
mIsActive[i] = PR_FALSE;
mActiveNum--;
if (mActiveNum <= 0)
{
mState = eNotMe;
break;
}
}
}
PR_FREEIF(newBuf1);
return mState;
}