本文整理汇总了C++中NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY函数的典型用法代码示例。如果您正苦于以下问题:C++ NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY函数的具体用法?C++ NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY怎么用?C++ NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: sizeof
/* void getInterfaces (out PRUint32 count, [array, size_is (count),
retval] out nsIIDPtr array); */
NS_IMETHODIMP
WSPProxy::GetInterfaces(PRUint32 *count, nsIID * **array)
{
if (!mIID) {
return NS_ERROR_NOT_INITIALIZED;
}
*count = 2;
nsIID** iids = static_cast<nsIID**>(nsMemory::Alloc(2 * sizeof(nsIID*)));
if (!iids) {
return NS_ERROR_OUT_OF_MEMORY;
}
iids[0] = static_cast<nsIID *>(nsMemory::Clone(mIID, sizeof(nsIID)));
if (NS_UNLIKELY(!iids[0])) {
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(0, iids);
return NS_ERROR_OUT_OF_MEMORY;
}
const nsIID& wsiid = NS_GET_IID(nsIWebServiceProxy);
iids[1] = static_cast<nsIID *>(nsMemory::Clone(&wsiid, sizeof(nsIID)));
if (NS_UNLIKELY(!iids[1])) {
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(1, iids);
return NS_ERROR_OUT_OF_MEMORY;
}
*array = iids;
return NS_OK;
}
开发者ID:EdgarChen,项目名称:mozilla-cvs-history,代码行数:31,代码来源:wspproxy.cpp
示例2: NS_ENSURE_ARG_POINTER
/* void Suggest (in wstring word, [array, size_is (count)] out wstring suggestions, out PRUint32 count); */
NS_IMETHODIMP mozHunspell::Suggest(const PRUnichar *aWord, PRUnichar ***aSuggestions, PRUint32 *aSuggestionCount)
{
NS_ENSURE_ARG_POINTER(aSuggestions);
NS_ENSURE_ARG_POINTER(aSuggestionCount);
NS_ENSURE_TRUE(mHunspell, NS_ERROR_FAILURE);
nsresult rv;
*aSuggestionCount = 0;
nsXPIDLCString charsetWord;
rv = ConvertCharset(aWord, getter_Copies(charsetWord));
NS_ENSURE_SUCCESS(rv, rv);
char ** wlst;
*aSuggestionCount = mHunspell->suggest(&wlst, charsetWord);
if (*aSuggestionCount) {
*aSuggestions = (PRUnichar **)nsMemory::Alloc(*aSuggestionCount * sizeof(PRUnichar *));
if (*aSuggestions) {
PRUint32 index = 0;
for (index = 0; index < *aSuggestionCount && NS_SUCCEEDED(rv); ++index) {
// Convert the suggestion to utf16
PRInt32 inLength = nsCRT::strlen(wlst[index]);
PRInt32 outLength;
rv = mDecoder->GetMaxLength(wlst[index], inLength, &outLength);
if (NS_SUCCEEDED(rv))
{
(*aSuggestions)[index] = (PRUnichar *) nsMemory::Alloc(sizeof(PRUnichar) * (outLength+1));
if ((*aSuggestions)[index])
{
rv = mDecoder->Convert(wlst[index], &inLength, (*aSuggestions)[index], &outLength);
if (NS_SUCCEEDED(rv))
(*aSuggestions)[index][outLength] = 0;
}
else
rv = NS_ERROR_OUT_OF_MEMORY;
}
}
if (NS_FAILED(rv))
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(index, *aSuggestions); // free the PRUnichar strings up to the point at which the error occurred
}
else // if (*aSuggestions)
rv = NS_ERROR_OUT_OF_MEMORY;
}
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(*aSuggestionCount, wlst);
return rv;
}
开发者ID:LittleForker,项目名称:mozilla-central,代码行数:50,代码来源:mozHunspell.cpp
示例3: nsDOMStringList
NS_IMETHODIMP
nsDOMOfflineResourceList::GetMozItems(nsIDOMDOMStringList **aItems)
{
*aItems = nsnull;
nsRefPtr<nsDOMStringList> items = new nsDOMStringList();
NS_ENSURE_TRUE(items, NS_ERROR_OUT_OF_MEMORY);
// If we are not associated with an application cache, return an
// empty list.
nsCOMPtr<nsIApplicationCache> appCache = GetDocumentAppCache();
if (!appCache) {
NS_ADDREF(*aItems = items);
return NS_OK;
}
nsresult rv = Init();
NS_ENSURE_SUCCESS(rv, rv);
PRUint32 length;
char **keys;
rv = appCache->GatherEntries(nsIApplicationCache::ITEM_DYNAMIC,
&length, &keys);
NS_ENSURE_SUCCESS(rv, rv);
for (PRUint32 i = 0; i < length; i++) {
items->Add(NS_ConvertUTF8toUTF16(keys[i]));
}
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(length, keys);
NS_ADDREF(*aItems = items);
return NS_OK;
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:34,代码来源:nsDOMOfflineResourceList.cpp
示例4: rootPref
NS_IMETHODIMP
nsMsgAccount::ClearAllValues()
{
nsresult rv;
nsCAutoString rootPref("mail.account.");
rootPref += m_accountKey;
rootPref += '.';
rv = getPrefService();
if (NS_FAILED(rv))
return rv;
PRUint32 cntChild, i;
char **childArray;
rv = m_prefs->GetChildList(rootPref.get(), &cntChild, &childArray);
if (NS_SUCCEEDED(rv)) {
for (i = 0; i < cntChild; i++)
m_prefs->ClearUserPref(childArray[i]);
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(cntChild, childArray);
}
return rv;
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:25,代码来源:nsMsgAccount.cpp
示例5: NS_ENSURE_SUCCESS
NS_IMETHODIMP
mozSpellChecker::CheckWord(const nsAString &aWord, bool *aIsMisspelled, nsTArray<nsString> *aSuggestions)
{
nsresult result;
bool correct;
if(!mSpellCheckingEngine)
return NS_ERROR_NULL_POINTER;
*aIsMisspelled = false;
result = mSpellCheckingEngine->Check(PromiseFlatString(aWord).get(), &correct);
NS_ENSURE_SUCCESS(result, result);
if(!correct){
if(aSuggestions){
uint32_t count,i;
PRUnichar **words;
result = mSpellCheckingEngine->Suggest(PromiseFlatString(aWord).get(), &words, &count);
NS_ENSURE_SUCCESS(result, result);
for(i=0;i<count;i++){
aSuggestions->AppendElement(nsDependentString(words[i]));
}
if (count)
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, words);
}
*aIsMisspelled = true;
}
return NS_OK;
}
开发者ID:Incognito,项目名称:mozilla-central,代码行数:29,代码来源:mozSpellChecker.cpp
示例6: NS_ENSURE_SUCCESS
/* void getKeyForTag (in wstring tag); */
NS_IMETHODIMP nsMsgTagService::GetKeyForTag(const nsAString &aTag, nsACString &aKey)
{
uint32_t count;
char **prefList;
nsresult rv = m_tagPrefBranch->GetChildList("", &count, &prefList);
NS_ENSURE_SUCCESS(rv, rv);
// traverse the list, and look for a pref with the desired tag value.
for (uint32_t i = count; i--;)
{
// We are returned the tag prefs in the form "<key>.<tag_data_type>", but
// since we only want the tags, just check that the string ends with "tag".
nsDependentCString prefName(prefList[i]);
if (StringEndsWith(prefName, NS_LITERAL_CSTRING(TAG_PREF_SUFFIX_TAG)))
{
nsAutoString curTag;
GetUnicharPref(prefList[i], curTag);
if (aTag.Equals(curTag))
{
aKey = Substring(prefName, 0, prefName.Length() - STRLEN(TAG_PREF_SUFFIX_TAG));
break;
}
}
}
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, prefList);
ToLowerCase(aKey);
return NS_OK;
}
开发者ID:Type-of-Tool,项目名称:ExMail,代码行数:28,代码来源:nsMsgTagService.cpp
示例7: NS_WARNING
nsresult
nsLDAPSyncQuery::OnLDAPSearchEntry(nsILDAPMessage *aMessage)
{
uint32_t attrCount;
char** attributes;
nsresult rv = aMessage->GetAttributes(&attrCount, &attributes);
if (NS_FAILED(rv))
{
NS_WARNING("nsLDAPSyncQuery:OnLDAPSearchEntry(): "
"aMessage->GetAttributes() failed");
FinishLDAPQuery();
return rv;
}
// Iterate through the attributes received in this message
for (uint32_t i = 0; i < attrCount; i++)
{
PRUnichar **vals;
uint32_t valueCount;
// Get the values of this attribute.
// XXX better failure handling
rv = aMessage->GetValues(attributes[i], &valueCount, &vals);
if (NS_FAILED(rv))
{
NS_WARNING("nsLDAPSyncQuery:OnLDAPSearchEntry(): "
"aMessage->GetValues() failed\n");
FinishLDAPQuery();
break;
}
// Store all values of this attribute in the mResults.
for (uint32_t j = 0; j < valueCount; j++) {
mResults.Append(PRUnichar('\n'));
mResults.AppendASCII(attributes[i]);
mResults.Append(PRUnichar('='));
mResults.Append(vals[j]);
}
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(valueCount, vals);
}
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(attrCount, attributes);
return rv;
}
开发者ID:Type-of-Tool,项目名称:ExMail,代码行数:45,代码来源:nsLDAPSyncQuery.cpp
示例8: NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY
void
nsDOMOfflineResourceList::ClearCachedKeys()
{
if (mCachedKeys) {
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(mCachedKeysCount, mCachedKeys);
mCachedKeys = nsnull;
mCachedKeysCount = 0;
}
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:9,代码来源:nsDOMOfflineResourceList.cpp
示例9: GetEngineList
NS_IMETHODIMP
mozSpellChecker::GetDictionaryList(nsTArray<nsString> *aDictionaryList)
{
nsresult rv;
// For catching duplicates
nsClassHashtable<nsStringHashKey, nsCString> dictionaries;
nsCOMArray<mozISpellCheckingEngine> spellCheckingEngines;
rv = GetEngineList(&spellCheckingEngines);
NS_ENSURE_SUCCESS(rv, rv);
for (int32_t i = 0; i < spellCheckingEngines.Count(); i++) {
nsCOMPtr<mozISpellCheckingEngine> engine = spellCheckingEngines[i];
uint32_t count = 0;
PRUnichar **words = nullptr;
engine->GetDictionaryList(&words, &count);
for (uint32_t k = 0; k < count; k++) {
nsAutoString dictName;
dictName.Assign(words[k]);
// Skip duplicate dictionaries. Only take the first one
// for each name.
if (dictionaries.Get(dictName, nullptr))
continue;
dictionaries.Put(dictName, nullptr);
if (!aDictionaryList->AppendElement(dictName)) {
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, words);
return NS_ERROR_OUT_OF_MEMORY;
}
}
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, words);
}
return NS_OK;
}
开发者ID:Incognito,项目名称:mozilla-central,代码行数:41,代码来源:mozSpellChecker.cpp
示例10: GetSignonFileName
nsresult
nsSeamonkeyProfileMigrator::CopyPasswords(PRBool aReplace)
{
nsresult rv;
nsCString signonsFileName;
GetSignonFileName(aReplace, getter_Copies(signonsFileName));
if (signonsFileName.IsEmpty())
return NS_ERROR_FILE_NOT_FOUND;
NS_ConvertASCIItoUTF16 fileName(signonsFileName);
if (aReplace)
rv = CopyFile(fileName, fileName);
else {
// Get the password manager, which is the destination for the passwords
// being migrated. Also create a new instance of the legacy password
// storage component, which we'll use to slurp in the signons from
// Seamonkey's signons.txt.
nsCOMPtr<nsILoginManager> pwmgr(
do_GetService("@mozilla.org/login-manager;1"));
nsCOMPtr<nsILoginManagerStorage> importer(
do_CreateInstance("@mozilla.org/login-manager/storage/legacy;1"));
nsCOMPtr<nsIFile> signonsFile;
mSourceProfile->Clone(getter_AddRefs(signonsFile));
signonsFile->Append(fileName);
importer->InitWithFile(signonsFile, nsnull);
PRUint32 count;
nsILoginInfo **logins;
rv = importer->GetAllLogins(&count, &logins);
NS_ENSURE_SUCCESS(rv, rv);
for (PRUint32 i = 0; i < count; i++) {
pwmgr->AddLogin(logins[i]);
}
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, logins);
PRUnichar **hostnames;
rv = importer->GetAllDisabledHosts(&count, &hostnames);
NS_ENSURE_SUCCESS(rv, rv);
for (PRUint32 i = 0; i < count; i++) {
pwmgr->SetLoginSavingEnabled(nsDependentString(hostnames[i]),
PR_FALSE);
}
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, hostnames);
}
return rv;
}
开发者ID:sahlberg,项目名称:timberwolf,代码行数:51,代码来源:nsSeamonkeyProfileMigrator.cpp
示例11: LoadExistingPrefs
void
LoadExistingPrefs()
{
uint32_t count;
char** names;
nsresult rv = Preferences::GetRootBranch()->
GetChildList(kLoggingPrefPrefix, &count, &names);
if (NS_SUCCEEDED(rv) && count) {
for (size_t i = 0; i < count; i++) {
LoadPrefValue(names[i]);
}
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, names);
}
}
开发者ID:MekliCZ,项目名称:positron,代码行数:14,代码来源:LogModulePrefWatcher.cpp
示例12: exportVirtualBoxVRDEServer
/**
* Export VirtualBox vrde server
*/
static void exportVirtualBoxVRDEServer(IVRDEServer *vrdeServer, xmlTextWriterPtr writer) {
nsresult rc;
// find info
PRBool enabled = PR_FALSE;
vrdeServer->GetEnabled(&enabled);
// vrde enabled
ADDXMLBOOL(vrdeServer->GetEnabled, "vrde");
if (enabled == PR_TRUE) {
// vrde extpack
ADDXMLSTRING(vrdeServer->GetVRDEExtPack, "vrde.ext");
// vrde auth lib
ADDXMLSTRING(vrdeServer->GetAuthLibrary, "vrde.authlib");
// vrde multicon
ADDXMLBOOL(vrdeServer->GetAllowMultiConnection, "vrde.multicon");
// vrde reusecon
ADDXMLBOOL(vrdeServer->GetReuseSingleConnection, "vrde.reusecon");
// vrde properties
{
PRUnichar **properties = nsnull;
PRUint32 propertiesCount = 0;
nsAutoString keyPrefix;
rc = vrdeServer->GetVRDEProperties(&propertiesCount, &properties);
if (NS_SUCCEEDED(rc)) {
for (PRUint32 i = 0; i < propertiesCount; i++) {
nsXPIDLString value;
rc = vrdeServer->GetVRDEProperty(properties[i], getter_Copies(value));
if (NS_SUCCEEDED(rc)) {
nsCAutoString key("vrde.");
key.AppendWithConversion(properties[i]);
WRITEXMLSTRING(convertString(key).c_str(), convertString(value));
}
}
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(propertiesCount, properties);
}
}
}
}
开发者ID:nitrotm,项目名称:virtualbox-php,代码行数:52,代码来源:machine.cpp
示例13: word
// Convert the list of words in iwords to the same capitalization aWord and
// return them in owords.
NS_IMETHODIMP mozEnglishWordUtils::FromRootForm(const char16_t *aWord, const char16_t **iwords, uint32_t icount, char16_t ***owords, uint32_t *ocount)
{
nsAutoString word(aWord);
nsresult rv = NS_OK;
int32_t length;
char16_t **tmpPtr = (char16_t **)moz_xmalloc(sizeof(char16_t *)*icount);
if (!tmpPtr)
return NS_ERROR_OUT_OF_MEMORY;
mozEnglishWordUtils::myspCapitalization ct = captype(word);
for(uint32_t i = 0; i < icount; ++i) {
length = NS_strlen(iwords[i]);
tmpPtr[i] = (char16_t *) moz_xmalloc(sizeof(char16_t) * (length + 1));
if (MOZ_UNLIKELY(!tmpPtr[i])) {
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(i, tmpPtr);
return NS_ERROR_OUT_OF_MEMORY;
}
memcpy(tmpPtr[i], iwords[i], (length + 1) * sizeof(char16_t));
nsAutoString capTest(tmpPtr[i]);
mozEnglishWordUtils::myspCapitalization newCt=captype(capTest);
if(newCt == NoCap){
switch(ct)
{
case HuhCap:
case NoCap:
break;
case AllCap:
ToUpperCase(tmpPtr[i],tmpPtr[i],length);
rv = NS_OK;
break;
case InitCap:
ToUpperCase(tmpPtr[i],tmpPtr[i],1);
rv = NS_OK;
break;
default:
rv = NS_ERROR_FAILURE; // should never get here;
break;
}
}
}
if (NS_SUCCEEDED(rv)){
*owords = tmpPtr;
*ocount = icount;
}
return rv;
}
开发者ID:heiher,项目名称:gecko-dev,代码行数:51,代码来源:mozEnglishWordUtils.cpp
示例14: FinishLDAPQuery
nsresult
nsLDAPSyncQuery::OnLDAPSearchResult(nsILDAPMessage *aMessage)
{
// We are done with the LDAP search.
// Release the control variable for the eventloop and other members
//
FinishLDAPQuery();
// Release memory allocated for mAttrs
if (mAttrCount > 0)
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(mAttrCount, mAttrs);
return NS_OK;
}
开发者ID:Anachid,项目名称:mozilla-central,代码行数:15,代码来源:nsLDAPSyncQuery.cpp
示例15: word
// Convert the list of words in iwords to the same capitalization aWord and
// return them in owords.
NS_IMETHODIMP mozEnglishWordUtils::FromRootForm(const PRUnichar *aWord, const PRUnichar **iwords, PRUint32 icount, PRUnichar ***owords, PRUint32 *ocount)
{
nsAutoString word(aWord);
nsresult rv = NS_OK;
PRInt32 length;
PRUnichar **tmpPtr = (PRUnichar **)nsMemory::Alloc(sizeof(PRUnichar *)*icount);
if (!tmpPtr)
return NS_ERROR_OUT_OF_MEMORY;
mozEnglishWordUtils::myspCapitalization ct = captype(word);
for(PRUint32 i = 0; i < icount; ++i) {
length = nsCRT::strlen(iwords[i]);
tmpPtr[i] = (PRUnichar *) nsMemory::Alloc(sizeof(PRUnichar) * (length + 1));
if (NS_UNLIKELY(!tmpPtr[i])) {
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(i, tmpPtr);
return NS_ERROR_OUT_OF_MEMORY;
}
memcpy(tmpPtr[i], iwords[i], (length + 1) * sizeof(PRUnichar));
nsAutoString capTest(tmpPtr[i]);
mozEnglishWordUtils::myspCapitalization newCt=captype(capTest);
if(newCt == NoCap){
switch(ct)
{
case HuhCap:
case NoCap:
break;
case AllCap:
rv = mCaseConv->ToUpper(tmpPtr[i],tmpPtr[i],length);
break;
case InitCap:
rv = mCaseConv->ToUpper(tmpPtr[i],tmpPtr[i],1);
break;
default:
rv = NS_ERROR_FAILURE; // should never get here;
break;
}
}
}
if (NS_SUCCEEDED(rv)){
*owords = tmpPtr;
*ocount = icount;
}
return rv;
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:49,代码来源:mozEnglishWordUtils.cpp
示例16: NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY
NS_IMETHODIMP
mozSpellChecker::GetDictionaryList(nsStringArray *aDictionaryList)
{
nsAutoString temp;
PRUint32 count,i;
PRUnichar **words;
if(!aDictionaryList || !mSpellCheckingEngine)
return NS_ERROR_NULL_POINTER;
mSpellCheckingEngine->GetDictionaryList(&words,&count);
for(i=0;i<count;i++){
temp.Assign(words[i]);
aDictionaryList->AppendString(temp);
}
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, words);
return NS_OK;
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:18,代码来源:mozSpellChecker.cpp
示例17: NS_WARNING
nsresult
nsLDAPSyncQuery::OnLDAPSearchEntry(nsILDAPMessage *aMessage)
{
nsresult rv;
// Attributes are retrieved in StartLDAPSearch
// iterate through them
//
for (PRUint32 i = 0; i < mAttrCount; i++) {
PRUnichar **vals;
PRUint32 valueCount;
// get the values of this attribute
// XXX better failure handling
//
rv = aMessage->GetValues(mAttrs[i], &valueCount, &vals);
if (NS_FAILED(rv)) {
NS_WARNING("nsLDAPSyncQuery:OnLDAPSearchEntry(): "
"aMessage->GetValues() failed\n");
FinishLDAPQuery();
return rv;;
}
// store all values of this attribute in the mResults.
//
for (PRUint32 j = 0; j < valueCount; j++) {
mResults.Append(PRUnichar('\n'));
mResults.AppendASCII(mAttrs[i]);
mResults.Append(PRUnichar('='));
mResults.Append(vals[j]);
}
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(valueCount, vals);
}
return NS_OK;
}
开发者ID:Anachid,项目名称:mozilla-central,代码行数:39,代码来源:nsLDAPSyncQuery.cpp
示例18: NS_ENSURE_SUCCESS
NS_IMETHODIMP
mozSpellChecker::CheckWord(const nsAString &aWord, PRBool *aIsMisspelled, nsStringArray *aSuggestions)
{
nsresult result;
PRBool correct;
if(!mSpellCheckingEngine)
return NS_ERROR_NULL_POINTER;
// don't bother to check crazy words, also, myspell gets unhappy if you
// give it too much data and crashes sometimes
if (aWord.Length() > UNREASONABLE_WORD_LENGTH) {
*aIsMisspelled = PR_TRUE;
return NS_OK;
}
*aIsMisspelled = PR_FALSE;
result = mSpellCheckingEngine->Check(PromiseFlatString(aWord).get(), &correct);
NS_ENSURE_SUCCESS(result, result);
if(!correct){
if(aSuggestions){
PRUint32 count,i;
PRUnichar **words;
result = mSpellCheckingEngine->Suggest(PromiseFlatString(aWord).get(), &words, &count);
NS_ENSURE_SUCCESS(result, result);
for(i=0;i<count;i++){
aSuggestions->AppendString(nsDependentString(words[i]));
}
if (count)
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, words);
}
if(aIsMisspelled){
*aIsMisspelled = PR_TRUE;
}
}
return NS_OK;
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:38,代码来源:mozSpellChecker.cpp
示例19: NS_ENSURE_ARG_POINTER
/* void getAllTags (out unsigned long count, [array, size_is (count), retval] out nsIMsgTag tagArray); */
NS_IMETHODIMP nsMsgTagService::GetAllTags(uint32_t *aCount, nsIMsgTag ***aTagArray)
{
NS_ENSURE_ARG_POINTER(aCount);
NS_ENSURE_ARG_POINTER(aTagArray);
// preset harmless default values
*aCount = 0;
*aTagArray = nullptr;
// get the actual tag definitions
nsresult rv;
uint32_t prefCount;
char **prefList;
rv = m_tagPrefBranch->GetChildList("", &prefCount, &prefList);
NS_ENSURE_SUCCESS(rv, rv);
// sort them by key for ease of processing
NS_QuickSort(prefList, prefCount, sizeof(char*), CompareMsgTagKeys, nullptr);
// build an array of nsIMsgTag elements from the orderered list
// it's at max the same size as the preflist, but usually only about half
nsIMsgTag** tagArray = (nsIMsgTag**) NS_Alloc(sizeof(nsIMsgTag*) * prefCount);
if (!tagArray)
{
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(prefCount, prefList);
return NS_ERROR_OUT_OF_MEMORY;
}
uint32_t currentTagIndex = 0;
nsMsgTag *newMsgTag;
nsString tag;
nsCString lastKey, color, ordinal;
for (uint32_t i = prefCount; i--;)
{
// extract just the key from <key>.<info=tag|color|ordinal>
char *info = strrchr(prefList[i], '.');
if (info)
{
nsCAutoString key(Substring(prefList[i], info));
if (key != lastKey)
{
if (!key.IsEmpty())
{
// .tag MUST exist (but may be empty)
rv = GetTagForKey(key, tag);
if (NS_SUCCEEDED(rv))
{
// .color MAY exist
color.Truncate();
GetColorForKey(key, color);
// .ordinal MAY exist
rv = GetOrdinalForKey(key, ordinal);
if (NS_FAILED(rv))
ordinal.Truncate();
// store the tag info in our array
newMsgTag = new nsMsgTag(key, tag, color, ordinal);
if (!newMsgTag)
{
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(currentTagIndex, tagArray);
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(prefCount, prefList);
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(tagArray[currentTagIndex++] = newMsgTag);
}
}
lastKey = key;
}
}
}
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(prefCount, prefList);
// sort the non-null entries by ordinal
NS_QuickSort(tagArray, currentTagIndex, sizeof(nsMsgTag*), CompareMsgTags,
nullptr);
// All done, now return the values (the idl's size_is(count) parameter
// ensures that the array is cut accordingly).
*aCount = currentTagIndex;
*aTagArray = tagArray;
return NS_OK;
}
开发者ID:Type-of-Tool,项目名称:ExMail,代码行数:82,代码来源:nsMsgTagService.cpp
示例20: exportVirtualBoxMachine
//.........这里部分代码省略.........
// medium attachments
{
IMediumAttachment **mediumAttachments = nsnull;
PRUint32 mediumAttachmentsCount = 0;
rc = machine->GetMediumAttachments(&mediumAttachmentsCount, &mediumAttachments);
if (NS_SUCCEEDED(rc)) {
for (PRUint32 i = 0; i < mediumAttachmentsCount; i++) {
exportVirtualBoxMediumAttachment(mediumAttachments[i], writer);
}
}
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(mediumAttachmentsCount, mediumAttachments);
}
// network adapters
{
PRUint32 networkAdaptersCount;
PRUint32 chipsetType;
rc = machine->GetChipsetType(&chipsetType);
if (NS_SUCCEEDED(rc)) {
rc = systemProperties->GetMaxNetworkAdapters(chipsetType, &networkAdaptersCount);
if (NS_SUCCEEDED(rc)) {
for (PRUint32 i = 0; i < networkAdaptersCount; i++) {
nsCOMPtr<INetworkAdapter> networkAdapter;
rc = machine->GetNetworkAdapter(i, getter_AddRefs(networkAdapter));
if (NS_SUCCEEDED(rc)) {
exportVirtualBoxNetworkAdapter(networkAdapter, i + 1, writer);
}
}
}
}
}
// uartX
// audio adapter
{
nsCOMPtr<IAudioAdapter> value;
rc = machine->GetAudioAdapter(getter_AddRefs(value));
if (NS_SUCCEEDED(rc)) {
exportVirtualBoxAudioAdapter(value, writer);
}
}
// vrde server
{
nsCOMPtr<IVRDEServer> value;
rc = machine->GetVRDEServer(getter_AddRefs(value));
if (NS_SUCCEEDED(rc)) {
exportVirtualBoxVRDEServer(value, writer);
}
}
// usb controllers
// {
// nsCOMPtr<IUSBController> value;
// rc = machine->GetUSBController(getter_AddRefs(value));
// if (NS_SUCCEEDED(rc)) {
// exportVirtualBoxUSBController(value, writer);
// }
// }
// guest properties
{
PRUnichar **names = nsnull;
PRUnichar **values = nsnull;
PRInt64 *timestamps = nsnull;
PRUnichar **flags = nsnull;
PRUint32 namesCount = 0;
PRUint32 valuesCount = 0;
PRUint32 timestampsCount = 0;
PRUint32 flagsCount = 0;
rc = machine->EnumerateGuestProperties((const PRUnichar*)nsnull, &namesCount, &names, &valuesCount, &values, ×tampsCount, ×tamps, &flagsCount, &flags);
if (NS_SUCCEEDED(rc)) {
for (PRUint32 i = 0; i < namesCount; i++) {
nsAutoString name(names[i]);
nsAutoString value(values[i]);
PRUint64 timestamp = timestamps[i];
nsAutoString flag(flags[i]);
WRITEXMLSTRING(convertString(name).c_str(), convertString(value));
}
}
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(namesCount, names);
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(valuesCount, values);
nsMemory::Free(timestamps);
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(flagsCount, flags);
}
xmlTextWriterEndElement(writer);
}
}
开发者ID:nitrotm,项目名称:virtualbox-php,代码行数:101,代码来源:machine.cpp
注:本文中的NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论