rv = content->GetAttrCount((PRInt32&)mNumCachedAttrs);
PRInt32 cattrs; rv = content->GetAttrCount(cattrs);
nsresult nsPluginInstanceOwner::EnsureCachedAttrParamArrays(){  if (mCachedAttrParamValues)    return NS_OK;  NS_PRECONDITION((((mNumCachedAttrs + mNumCachedParams) == 0) && !mCachedAttrParamNames),                  "re-cache of attrs/params not implemented! use the DOM node directy instead");  NS_ENSURE_TRUE(mOwner, NS_ERROR_NULL_POINTER);  // first, we need to find out how much we need to allocate for our arrays  // count up attributes  mNumCachedAttrs = 0;  nsCOMPtr<nsIContent> content;   nsresult rv = mOwner->GetContent(getter_AddRefs(content));  NS_ENSURE_TRUE(content, rv);  rv = content->GetAttrCount((PRInt32&)mNumCachedAttrs); // signed 32 bits to unsigned 16 bits conversion  NS_ENSURE_SUCCESS(rv, rv);  // now, we need to find all the PARAM tags that are children of us  // however, be carefull NOT to include any PARAMs that don't have us as a direct  // parent. For nested object (or applet) tags, be sure to only round up the  // param tags that coorespond with THIS instance. And also, weed out any bogus  // tags that may get in the way, see bug 39609. Then, with any param tag that meet our  // qualification, temporarly cache them in an nsISupportsArray until we can figure out  // what size to make our fixed char* array.  mNumCachedParams = 0;  nsCOMPtr<nsISupportsArray> ourParams;  rv = NS_NewISupportsArray(getter_AddRefs(ourParams));  NS_ENSURE_SUCCESS(rv, rv);   nsCOMPtr<nsIDOMNode> mydomNode = do_QueryInterface(content);  NS_ENSURE_TRUE(mydomNode, NS_ERROR_NO_INTERFACE);    // use the DOM to get us ALL our dependant PARAM tags, even if not ours  nsCOMPtr<nsIDOMElement> mydomElement = do_QueryInterface(mydomNode);  NS_ENSURE_TRUE(mydomElement, NS_ERROR_NO_INTERFACE);  nsCOMPtr<nsIDOMNodeList> allParams;   mydomElement->GetElementsByTagName(NS_LITERAL_STRING("PARAM"), getter_AddRefs(allParams));  if (allParams) {    PRUint32 numAllParams;     allParams->GetLength(&numAllParams);    // loop through every so called dependant PARAM tag to check if it "belongs" to us    for (PRUint32 i = 0; i < numAllParams; i++) {      nsCOMPtr<nsIDOMNode> pnode;      allParams->Item(i, getter_AddRefs(pnode));      if (pnode) {        nsCOMPtr<nsIDOMElement> domelement = do_QueryInterface(pnode);        if (domelement) {          // let's NOT count up param tags that don't have a name attribute          nsAutoString name;          domelement->GetAttribute(NS_LITERAL_STRING("name"), name);          if (name.Length() > 0) {            nsCOMPtr<nsIDOMNode> parent;            nsCOMPtr<nsIDOMHTMLObjectElement> domobject;            nsCOMPtr<nsIDOMHTMLAppletElement> domapplet;            pnode->GetParentNode(getter_AddRefs(parent));            // walk up the parents of this PARAM until we find an object (or applet) tag            while (!(domobject || domapplet) && parent) {              domobject = do_QueryInterface(parent);              domapplet = do_QueryInterface(parent);              nsCOMPtr<nsIDOMNode> temp;              parent->GetParentNode(getter_AddRefs(temp));              parent = temp;            }            if (domapplet || domobject) {              if (domapplet)                parent = do_QueryInterface(domapplet);              else                parent = do_QueryInterface(domobject);              // now check to see if this PARAM's parent is us. if so, cache it for later              if (parent.get() == mydomNode.get()) {                nsCOMPtr<nsISupports> sup = do_QueryInterface(pnode);                NS_ASSERTION(sup,  "lame! DOM node does doesn't QI to nsISupports");                ourParams->AppendElement(sup);              }            }          }        }      }    }  }  ourParams->Count((PRUint32*)&mNumCachedParams); // unsigned 32 bits to unsigned 16 bits conversion  // now lets make the arrays  mCachedAttrParamNames  = (char **)PR_Calloc(sizeof(char *) * (mNumCachedAttrs + 1 + mNumCachedParams), 1);  NS_ENSURE_TRUE(mCachedAttrParamNames,  NS_ERROR_OUT_OF_MEMORY);  mCachedAttrParamValues = (char **)PR_Calloc(sizeof(char *) * (mNumCachedAttrs + 1 + mNumCachedParams), 1);  NS_ENSURE_TRUE(mCachedAttrParamValues, NS_ERROR_OUT_OF_MEMORY);  // let's fill in our attributes  PRInt16 c = 0;  for (PRInt16 index = 0; index < mNumCachedAttrs; index++) {    PRInt32 nameSpaceID;    nsCOMPtr<nsIAtom> atom;    nsCOMPtr<nsIAtom> prefix;    content->GetAttrNameAt(index, nameSpaceID,                           *getter_AddRefs(atom),                           *getter_AddRefs(prefix));    nsAutoString value;    if (NS_CONTENT_ATTR_NOT_THERE != content->GetAttr(nameSpaceID, atom, value)) {      nsAutoString name;      atom->ToString(name);      mCachedAttrParamNames [c] = ToNewUTF8String(name);      mCachedAttrParamValues[c] = ToNewUTF8String(value);      c++;    }  }  // add our PARAM and null seperator  mCachedAttrParamNames [mNumCachedAttrs + 1] = "PARAM";  mCachedAttrParamValues[mNumCachedAttrs + 1] = nsnull;  // now fill in the PARAM name/value pairs from the cached DOM nodes  c = 0;  for (PRInt16 idx = 0; idx < mNumCachedParams; idx++) {    nsCOMPtr<nsISupports> sup = ourParams->ElementAt(idx);    if (sup) {     nsCOMPtr<nsIDOMElement> param = do_QueryInterface(sup);     if (param) {       nsAutoString name;       nsAutoString value;       param->GetAttribute(NS_LITERAL_STRING("name"), name); // check for empty done above       param->GetAttribute(NS_LITERAL_STRING("value"), value);       /*        * According to the HTML 4.01 spec, at        * http://www.w3.org/TR/html4/types.html#type-cdata        * ''User agents may ignore leading and trailing        * white space in CDATA attribute values (e.g., "        * myval " may be interpreted as "myval"). Authors        * should not declare attribute values with        * leading or trailing white space.''        */                   name.CompressWhitespace();  // XXX right function?       value.CompressWhitespace();       mCachedAttrParamNames [mNumCachedAttrs + 1 + c] = ToNewUTF8String(name);       mCachedAttrParamValues[mNumCachedAttrs + 1 + c] = ToNewUTF8String(value);       c++;                                                      // rules!     }    }  }  return NS_OK;}