• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ NS_strdup函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16:

NS_IMETHODIMP
nsBaseDOMException::GetMessageMoz(char **aMessage)
{
  if (mMessage) {
    *aMessage = NS_strdup(mMessage);
  } else {
    *aMessage = nsnull;
  }

  return NS_OK;
}
开发者ID:b2gautomation,项目名称:mozilla-central,代码行数:11,代码来源:nsDOMException.cpp


示例17: NS_PRECONDITION

NS_IMETHODIMP
FileSystemDataSource::GetURI(char **uri)
{
    NS_PRECONDITION(uri != nullptr, "null ptr");
    if (! uri)
        return NS_ERROR_NULL_POINTER;

    if ((*uri = NS_strdup("rdf:files")) == nullptr)
        return NS_ERROR_OUT_OF_MEMORY;

    return NS_OK;
}
开发者ID:nafis-sadik,项目名称:gecko-dev,代码行数:12,代码来源:nsFileSystemDataSource.cpp


示例18: 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


示例19: NS_strdup

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


示例20: SetNameToNoString

NS_IMETHODIMP
nsJSID::GetName(char * *aName)
{
    if (!aName)
        return NS_ERROR_NULL_POINTER;

    if (!NameIsSet())
        SetNameToNoString();
    NS_ASSERTION(mName, "name not set");
    *aName = NS_strdup(mName);
    return *aName ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
开发者ID:Type-of-Tool,项目名称:ExMail,代码行数:12,代码来源:XPCJSID.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ NT2_HORNER_COEFF_T函数代码示例发布时间:2022-05-30
下一篇:
C++ NS_WARN_IF_FALSE函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap