当前位置: 首页>>代码示例>>C++>>正文


C++ PR_FREEIF函数代码示例

本文整理汇总了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);
}
开发者ID:MoonchildProductions,项目名称:FossaMail,代码行数:17,代码来源:mimetext.cpp

示例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;
}
开发者ID:alanyjw,项目名称:comm-central,代码行数:17,代码来源:nsMsgAppleDoubleEncode.cpp

示例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);
}
开发者ID:fortunto2,项目名称:celtx,代码行数:17,代码来源:nsFileStreams.cpp

示例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;
}
开发者ID:Type-of-Tool,项目名称:ExMail,代码行数:46,代码来源:mimehdrs.cpp

示例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);
    }
  }
}
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:45,代码来源:nsDirPrefs.cpp

示例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;
}
开发者ID:Incognito,项目名称:mozilla-central,代码行数:44,代码来源:nsCollationMacUC.cpp

示例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;
}
开发者ID:Type-of-Tool,项目名称:ExMail,代码行数:46,代码来源:mimemrel.cpp

示例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;
}
开发者ID:MoonchildProductions,项目名称:FossaMail,代码行数:44,代码来源:mimemalt.cpp

示例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);
  }
}
开发者ID:ameyapg,项目名称:webcl-firefox,代码行数:20,代码来源:WebCL_libcl.cpp

示例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;
}
开发者ID:vanto,项目名称:comm-central,代码行数:19,代码来源:nsMsgSendPart.cpp

示例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;
}
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:20,代码来源:nsVCardObj.cpp

示例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;
  }
}
开发者ID:MoonchildProductions,项目名称:FossaMail,代码行数:42,代码来源:nsURLFetcher.cpp

示例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);
}
开发者ID:Type-of-Tool,项目名称:ExMail,代码行数:21,代码来源:nsIMAPBodyShell.cpp

示例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);
}
开发者ID:leofiore,项目名称:enigfox,代码行数:22,代码来源:nsMsgComposeSecure.cpp

示例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;
}
开发者ID:yaoweibin,项目名称:libcharguess,代码行数:39,代码来源:SBCSGroupProber.cpp


注:本文中的PR_FREEIF函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。