diff --git a/mozilla/netwerk/cache/src/nsCacheEntry.cpp b/mozilla/netwerk/cache/src/nsCacheEntry.cpp index 875fdc83c5c..305533e1317 100644 --- a/mozilla/netwerk/cache/src/nsCacheEntry.cpp +++ b/mozilla/netwerk/cache/src/nsCacheEntry.cpp @@ -109,7 +109,11 @@ nsCacheEntry::SetMetaDataElement( const nsAReadableCString& key, if (!mMetaData) return NS_ERROR_OUT_OF_MEMORY; } - return mMetaData->SetElement(&key, &value); + nsresult rv = mMetaData->SetElement(key, value); + if (NS_SUCCEEDED(rv)) + MarkMetaDataDirty(); + + return rv; } diff --git a/mozilla/netwerk/cache/src/nsCacheMetaData.cpp b/mozilla/netwerk/cache/src/nsCacheMetaData.cpp index 6c25906720b..b1b090c408c 100644 --- a/mozilla/netwerk/cache/src/nsCacheMetaData.cpp +++ b/mozilla/netwerk/cache/src/nsCacheMetaData.cpp @@ -84,31 +84,29 @@ nsCacheMetaData::GetElement(const nsAReadableCString * key) nsresult -nsCacheMetaData::SetElement(const nsAReadableCString * key, - const nsAReadableCString * value) +nsCacheMetaData::SetElement(const nsAReadableCString& key, + const nsAReadableCString& value) { nsCacheMetaDataHashTableEntry * metaEntry; NS_ASSERTION(initialized, "nsCacheMetaDataHashTable not initialized"); - if (!key) return NS_ERROR_NULL_POINTER; - //** should value == nsnull remove the key? + + //** should empty value remove the key? metaEntry = (nsCacheMetaDataHashTableEntry *) - PL_DHashTableOperate(&table, key, PL_DHASH_ADD); + PL_DHashTableOperate(&table, &key, PL_DHASH_ADD); if (metaEntry->key == nsnull) { - metaEntry->key = new nsCString(*key); + metaEntry->key = new nsCString(key); if (metaEntry->key == nsnull) return NS_ERROR_OUT_OF_MEMORY; } if (metaEntry->value != nsnull) delete metaEntry->value; - if (value) { - metaEntry->value = new nsCString(*value); - if (metaEntry->value == nsnull) - return NS_ERROR_OUT_OF_MEMORY; - } else { - metaEntry->value = nsnull; + metaEntry->value = new nsCString(value); + if (metaEntry->value == nsnull) { + //** remove key? + return NS_ERROR_OUT_OF_MEMORY; } return NS_OK; diff --git a/mozilla/netwerk/cache/src/nsCacheMetaData.h b/mozilla/netwerk/cache/src/nsCacheMetaData.h index cfdab5c30a2..6b7d1af594e 100644 --- a/mozilla/netwerk/cache/src/nsCacheMetaData.h +++ b/mozilla/netwerk/cache/src/nsCacheMetaData.h @@ -53,8 +53,8 @@ public: nsAReadableCString * GetElement(const nsAReadableCString * key); - nsresult SetElement(const nsAReadableCString * key, - const nsAReadableCString * value); + nsresult SetElement(const nsAReadableCString& key, + const nsAReadableCString& value); nsresult GetKeyValueArray(nsCacheMetaDataKeyValuePair ** array, PRUint32 * count);