char * cStr = str.ToNewCString();
char * cStr = ToNewCString(str);
nsEventStatus PR_CALLBACK HandleSiteEvent(nsGUIEvent *aEvent){  nsEventStatus result = nsEventStatus_eIgnore;  if (aEvent == nsnull || aEvent->widget == nsnull) {    return result;  }  switch(aEvent->message) {    case NS_MOUSE_LEFT_BUTTON_UP: {      if (aEvent->widget->GetNativeData(NS_NATIVE_WIDGET) == GetWidgetNativeData(mSiteCancelBtn)) {        NS_ShowWidget(mSiteDialog,PR_FALSE);      } else if (aEvent->widget->GetNativeData(NS_NATIVE_WIDGET) == GetWidgetNativeData(mSiteIndexTxt)) {        // no op      } else {        PRInt32 oldIndex = gTop100Pointer;        if (aEvent->widget->GetNativeData(NS_NATIVE_WIDGET) == GetWidgetNativeData(mSitePrevBtn)) {          gTop100Pointer--;        } else if (aEvent->widget->GetNativeData(NS_NATIVE_WIDGET) == GetWidgetNativeData(mSiteNextBtn)) {          gTop100Pointer++;        } else {          nsString str;          PRUint32 size;          PRInt32  inx;          mSiteIndexTxt->GetText(str, 255, size);          char * cStr = str.ToNewCString();          sscanf(cStr, "%d", &inx);          if (inx >= 0 && inx < gTop100LastPointer) {            gTop100Pointer = inx;          }          delete[] cStr;        }        PRBool loadPage = PR_FALSE;        if (gTop100Pointer < 0) {          gTop100Pointer = 0;        } else if (gTop100Pointer >= gTop100LastPointer) {          gTop100Pointer = gTop100LastPointer-1;        } else {          loadPage = PR_TRUE;        }        NS_EnableWidget(mSitePrevBtn, gTop100Pointer > 0);        NS_EnableWidget(mSiteNextBtn, gTop100Pointer < (gTop100LastPointer-1));        if (gWinData && loadPage && oldIndex != gTop100Pointer) {          nsString urlStr; urlStr.AssignWithConversion(gTop100List[gTop100Pointer]);          mSiteLabel->SetLabel(urlStr);          gWinData->GoTo(urlStr.get());        }        nsAutoString str;        str.AppendInt(gTop100Pointer);        PRUint32 size;        mSiteIndexTxt->SetText(str, size);      }      } break;            case NS_PAINT: #ifndef XP_UNIX        // paint the background        if (aEvent->widget->GetNativeData(NS_NATIVE_WIDGET) == GetWidgetNativeData(mSiteDialog) ) {            nsIRenderingContext *drawCtx = ((nsPaintEvent*)aEvent)->renderingContext;            drawCtx->SetColor(aEvent->widget->GetBackgroundColor());            drawCtx->FillRect(*(((nsPaintEvent*)aEvent)->rect));            return nsEventStatus_eIgnore;        }#endif      break;      default:        result = nsEventStatus_eIgnore;    }    return result;}