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


C++ NS_strdup函数代码示例

本文整理汇总了C++中NS_strdup函数的典型用法代码示例。如果您正苦于以下问题:C++ NS_strdup函数的具体用法?C++ NS_strdup怎么用?C++ NS_strdup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NS_strdup函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: NS_ASSERTION

nsIMAPBodyShell::nsIMAPBodyShell(nsImapProtocol *protocolConnection,
                                 nsIMAPBodypartMessage *message, uint32_t UID,
                                 const char *folderName)
{
  m_isValid = false;
  m_isBeingGenerated = false;
  m_cached = false;
  m_gotAttachmentPref = false;
  m_generatingWholeMessage = false;
  m_generatingPart = NULL;
  m_protocolConnection = protocolConnection;
  m_message = message;
  NS_ASSERTION(m_protocolConnection, "non null connection");
  if (!m_protocolConnection)
    return;
  m_prefetchQueue = new nsIMAPMessagePartIDArray();
  if (!m_prefetchQueue)
    return;
  m_UID = "";
  m_UID.AppendInt(UID);
#ifdef DEBUG_chrisf
  NS_ASSERTION(folderName);
#endif
  if (!folderName)
    return;
  m_folderName = NS_strdup(folderName);
  if (!m_folderName)
    return;
  
  SetContentModified(GetShowAttachmentsInline() ? IMAP_CONTENT_MODIFIED_VIEW_INLINE : IMAP_CONTENT_MODIFIED_VIEW_AS_LINKS);

  SetIsValid(m_message != nullptr);
}
开发者ID:Type-of-Tool,项目名称:ExMail,代码行数:33,代码来源:nsIMAPBodyShell.cpp

示例2: NS_strdup

/* static */
char *nsIMAPNamespaceList::AllocateServerFolderName(const char *canonicalFolderName, char delimiter)
{
    if (delimiter)
        return nsImapUrl::ReplaceCharsInCopiedString(canonicalFolderName, '/', delimiter);
    else
        return NS_strdup(canonicalFolderName);
}
开发者ID:dualsky,项目名称:FossaMail,代码行数:8,代码来源:nsIMAPNamespace.cpp

示例3: UniCreateLocaleObject

nsresult nsCollationOS2::AllocateRawSortKey(int32_t strength, 
                                            const nsAString& stringIn, uint8_t** key, uint32_t* outLen)
{
  nsresult res = NS_OK;

  nsAutoString stringNormalized;
  if (strength != kCollationCaseSensitive) {
    res = mCollation->NormalizeString(stringIn, stringNormalized);
    if (NS_FAILED(res))
      return res;
  } else {
    stringNormalized = stringIn;
  }

  LocaleObject locObj = nullptr;
  int ret = UniCreateLocaleObject(UNI_UCS_STRING_POINTER, (UniChar *)L"", &locObj);
  if (ret != ULS_SUCCESS)
    UniCreateLocaleObject(UNI_UCS_STRING_POINTER, (UniChar *)L"C", &locObj);

  res = NS_ERROR_FAILURE;               // From here on out assume failure...
  int length = UniStrxfrm(locObj,
                          nullptr,
                          reinterpret_cast<const UniChar *>(stringNormalized.get()),
                          0);
  if (length >= 0) {
    length += 5;                        // Allow for the "extra" chars UniStrxfrm()
                                        //  will out put (overrunning the buffer if
                                        // you let it...)
    // Magic, persistent buffer.  If it's not twice the size we need,
    // we grow/reallocate it 4X so it doesn't grow often.
    static UniChar* pLocalBuffer = nullptr;
    static int iBufferLength = 100;
    if (iBufferLength < length*2) {
      if ( pLocalBuffer ) {
        free(pLocalBuffer);
        pLocalBuffer = nullptr;
      }
      iBufferLength = length*4;
    }
    if (!pLocalBuffer)
      pLocalBuffer = (UniChar*) malloc(sizeof(UniChar) * iBufferLength);
    if (pLocalBuffer) {
      // Do the Xfrm
      int uLen = UniStrxfrm(locObj, pLocalBuffer, reinterpret_cast<const UniChar *>(stringNormalized.get()), iBufferLength);
      // See how big the result really is
      uLen = UniStrlen(pLocalBuffer);
      // make sure it will fit in the output buffer...
      if (uLen < iBufferLength) {
          // Success!
          // Give 'em the real size in bytes...
          *key = (uint8_t *)NS_strdup((char16_t*) pLocalBuffer);
          *outLen = uLen * 2 + 2;
          res = NS_OK;
      }
    }
  }
  UniFreeLocaleObject(locObj);

  return res;
}
开发者ID:ConradIrwin,项目名称:gecko-dev,代码行数:60,代码来源:nsCollationOS2.cpp

示例4: NS_ENSURE_TRUE

NS_IMETHODIMP
nsStrictTransportSecurityService::ProcessStsHeader(nsIURI* aSourceURI,
                                                   const char* aHeader,
                                                   uint64_t *aMaxAge,
                                                   bool *aIncludeSubdomains)
{
  // Should be called on the main thread (or via proxy) since the permission
  // manager is used and it's not threadsafe.
  NS_ENSURE_TRUE(NS_IsMainThread(), NS_ERROR_UNEXPECTED);

  if (aMaxAge != nullptr) {
    *aMaxAge = 0;
  }

  if (aIncludeSubdomains != nullptr) {
    *aIncludeSubdomains = false;
  }

  char * header = NS_strdup(aHeader);
  if (!header) return NS_ERROR_OUT_OF_MEMORY;
  nsresult rv = ProcessStsHeaderMutating(aSourceURI, header, aMaxAge,
                                         aIncludeSubdomains);
  NS_Free(header);
  return rv;
}
开发者ID:AshishNamdev,项目名称:mozilla-central,代码行数:25,代码来源:nsStrictTransportSecurityService.cpp

示例5: NS_PRECONDITION

NS_IMETHODIMP nsImportService::GetModuleDescription(const char *filter, int32_t index, char16_t **_retval)
{
    NS_PRECONDITION(_retval != nullptr, "null ptr");
    if (!_retval)
        return NS_ERROR_NULL_POINTER;

  *_retval = nullptr;

    DoDiscover();
    if (!m_pModules)
    return NS_ERROR_FAILURE;

  if ((index < 0) || (index >= m_pModules->GetCount()))
    return NS_ERROR_FAILURE;

  ImportModuleDesc *  pDesc;
  int32_t  count = 0;
  for (int32_t i = 0; i < m_pModules->GetCount(); i++) {
    pDesc = m_pModules->GetModuleDesc(i);
    if (pDesc->SupportsThings(filter)) {
      if (count == index) {
        *_retval = NS_strdup(pDesc->GetDescription());
        return NS_OK;
      }
      else
        count++;
    }
  }

  return NS_ERROR_FAILURE;
}
开发者ID:cristiklein,项目名称:comm-central,代码行数:31,代码来源:nsImportService.cpp

示例6: NS_ENSURE_ARG_POINTER

NS_IMETHODIMP
nsMemoryCacheDeviceInfo::GetDescription(char ** result)
{
    NS_ENSURE_ARG_POINTER(result);
    *result = NS_strdup("Memory cache device");
    if (!*result) return NS_ERROR_OUT_OF_MEMORY;
    return NS_OK;
}
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:8,代码来源:nsMemoryCacheDevice.cpp

示例7: NS_strdup

nsMsgSearchValueImpl::nsMsgSearchValueImpl(nsMsgSearchValue *aInitialValue)
{
    mValue = *aInitialValue;
    if (IS_STRING_ATTRIBUTE(aInitialValue->attribute) && aInitialValue->string)
        mValue.string = NS_strdup(aInitialValue->string);
    else
        mValue.string = 0;
}
开发者ID:Type-of-Tool,项目名称:ExMail,代码行数:8,代码来源:nsMsgSearchValue.cpp

示例8: NS_ASSERTION

bool
nsJSID::SetName(const char* name)
{
    NS_ASSERTION(!mName || mName == gNoString ,"name already set");
    NS_ASSERTION(name,"null name");
    mName = NS_strdup(name);
    return mName ? true : false;
}
开发者ID:Type-of-Tool,项目名称:ExMail,代码行数:8,代码来源:XPCJSID.cpp

示例9: NS_ASSERTION

PRBool
nsJSID::SetName(const char* name)
{
    NS_ASSERTION(!mName || mName == gNoString ,"name already set");
    NS_ASSERTION(name,"null name");
    mName = NS_strdup(name);
    return mName ? PR_TRUE : PR_FALSE;
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:8,代码来源:xpcjsid.cpp

示例10: NS_ENSURE_ARG_POINTER

NS_IMETHODIMP
nsCacheEntryInfo::GetDeviceID(char ** deviceID)
{
    NS_ENSURE_ARG_POINTER(deviceID);
    if (!mCacheEntry)  return NS_ERROR_NOT_AVAILABLE;

    *deviceID = NS_strdup(mCacheEntry->GetDeviceID());
    return *deviceID ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
开发者ID:MozillaOnline,项目名称:gecko-dev,代码行数:9,代码来源:nsCacheEntry.cpp

示例11: k

char*
nsInt2StrHashtable::Get(uint32_t key)
{
    nsPRUint32Key k(key);
    const char* value = (const char*)mHashtable.Get(&k);
    if (value == nullptr)
        return nullptr;
    return NS_strdup(value);
}
开发者ID:excitedhoney,项目名称:firefox,代码行数:9,代码来源:nsErrorService.cpp

示例12: mAtom

nsAtomStringList::nsAtomStringList(nsIAtom* aAtom, const PRUnichar* aString)
  : mAtom(aAtom),
    mString(nsnull),
    mNext(nsnull)
{
  MOZ_COUNT_CTOR(nsAtomStringList);
  if (aString)
    mString = NS_strdup(aString);
}
开发者ID:ahadzi,项目名称:celtx,代码行数:9,代码来源:nsCSSStyleRule.cpp

示例13: SetAllocatedString

// Copied from toolkit/xre/nsAppData.cpp.
void SetAllocatedString(const char *&str, const char *newvalue)
{
  NS_Free(const_cast<char*>(str));
  if (newvalue) {
    str = NS_strdup(newvalue);
  }
  else {
    str = nullptr;
  }
}
开发者ID:hideakihata,项目名称:mozilla-central.fgv,代码行数:11,代码来源:webapprt.cpp

示例14: SetAllocatedString

void
SetAllocatedString(const char*& aStr, const char* aNewValue)
{
  NS_Free(const_cast<char*>(aStr));
  if (aNewValue) {
    aStr = NS_strdup(aNewValue);
  } else {
    aStr = nullptr;
  }
}
开发者ID:L2-D2,项目名称:gecko-dev,代码行数:10,代码来源:AppData.cpp

示例15: mType

nsPseudoClassList::nsPseudoClassList(nsCSSPseudoClasses::Type aType,
                                     const PRUnichar* aString)
  : mType(aType),
    mNext(nsnull)
{
  NS_ASSERTION(nsCSSPseudoClasses::HasStringArg(aType),
               "unexpected pseudo-class");
  NS_ASSERTION(aString, "string expected");
  MOZ_COUNT_CTOR(nsPseudoClassList);
  u.mString = NS_strdup(aString);
}
开发者ID:mbrubeck,项目名称:mozilla-central,代码行数:11,代码来源:StyleRule.cpp


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