本文整理汇总了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);
}
示例2: NS_strdup
/* static */
char *nsIMAPNamespaceList::AllocateServerFolderName(const char *canonicalFolderName, char delimiter)
{
if (delimiter)
return nsImapUrl::ReplaceCharsInCopiedString(canonicalFolderName, '/', delimiter);
else
return NS_strdup(canonicalFolderName);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
}
示例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;
}
}
示例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);
}