update_engine: replace scoped_ptr_malloc with scoped_ptr
scoped_ptr_malloc<T, D> has been deprecated and will be removed. This CL
updates update_engine to use the equivalent scoped_ptr<T, D> instead.
BUG=chromium:366763
TEST=`FEATURES=test emerge-$BOARD platform2 update_engine`
Change-Id: If59103b1f1a7dceb1daa7b54af799af88518e6a4
Reviewed-on: https://chromium-review.googlesource.com/196878
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
diff --git a/omaha_request_action.cc b/omaha_request_action.cc
index bd5993d..9c5bbf5 100644
--- a/omaha_request_action.cc
+++ b/omaha_request_action.cc
@@ -62,8 +62,7 @@
// This is handy for passing strings into libxml2
#define ConstXMLStr(x) (reinterpret_cast<const xmlChar*>(x))
-// These are for scoped_ptr_malloc, which is like scoped_ptr, but allows
-// a custom free() function to be specified.
+// These are for scoped_ptr with a custom free function to be specified.
class ScopedPtrXmlDocFree {
public:
inline void operator()(void* x) const {
@@ -284,13 +283,13 @@
string XmlEncode(const string& input) {
// // TODO(adlr): if allocating a new xmlDoc each time is taking up too much
// // cpu, considering creating one and caching it.
- // scoped_ptr_malloc<xmlDoc, ScopedPtrXmlDocFree> xml_doc(
+ // scoped_ptr<xmlDoc, ScopedPtrXmlDocFree> xml_doc(
// xmlNewDoc(ConstXMLStr("1.0")));
// if (!xml_doc.get()) {
// LOG(ERROR) << "Unable to create xmlDoc";
// return "";
// }
- scoped_ptr_malloc<xmlChar, ScopedPtrXmlFree> str(
+ scoped_ptr<xmlChar, ScopedPtrXmlFree> str(
xmlEncodeEntitiesReentrant(NULL, ConstXMLStr(input.c_str())));
return string(reinterpret_cast<const char *>(str.get()));
}
@@ -452,7 +451,7 @@
xmlXPathObject* GetNodeSet(xmlDoc* doc, const xmlChar* xpath) {
xmlXPathObject* result = NULL;
- scoped_ptr_malloc<xmlXPathContext, ScopedPtrXmlXPathContextFree> context(
+ scoped_ptr<xmlXPathContext, ScopedPtrXmlXPathContextFree> context(
xmlXPathNewContext(doc));
if (!context.get()) {
LOG(ERROR) << "xmlXPathNewContext() returned NULL";
@@ -479,7 +478,7 @@
string XmlGetProperty(xmlNode* node, const char* name) {
if (!xmlHasProp(node, ConstXMLStr(name)))
return "";
- scoped_ptr_malloc<xmlChar, ScopedPtrXmlFree> str(
+ scoped_ptr<xmlChar, ScopedPtrXmlFree> str(
xmlGetProp(node, ConstXMLStr(name)));
string ret(reinterpret_cast<const char *>(str.get()));
return ret;
@@ -503,7 +502,7 @@
bool UpdateLastPingDays(xmlDoc* doc, PrefsInterface* prefs) {
static const char kDaystartNodeXpath[] = "/response/daystart";
- scoped_ptr_malloc<xmlXPathObject, ScopedPtrXmlXPathObjectFree>
+ scoped_ptr<xmlXPathObject, ScopedPtrXmlXPathObjectFree>
xpath_nodeset(GetNodeSet(doc, ConstXMLStr(kDaystartNodeXpath)));
TEST_AND_RETURN_FALSE(xpath_nodeset.get());
xmlNodeSet* nodeset = xpath_nodeset->nodesetval;
@@ -532,7 +531,7 @@
ScopedActionCompleter* completer) {
static const char* kUpdatecheckNodeXpath("/response/app/updatecheck");
- scoped_ptr_malloc<xmlXPathObject, ScopedPtrXmlXPathObjectFree>
+ scoped_ptr<xmlXPathObject, ScopedPtrXmlXPathObjectFree>
xpath_nodeset(GetNodeSet(doc, ConstXMLStr(kUpdatecheckNodeXpath)));
if (!xpath_nodeset.get()) {
completer->set_code(kErrorCodeOmahaResponseInvalid);
@@ -631,7 +630,7 @@
// Get the update URL.
static const char* kUpdateUrlNodeXPath("/response/app/updatecheck/urls/url");
- scoped_ptr_malloc<xmlXPathObject, ScopedPtrXmlXPathObjectFree>
+ scoped_ptr<xmlXPathObject, ScopedPtrXmlXPathObjectFree>
xpath_nodeset(GetNodeSet(doc, ConstXMLStr(kUpdateUrlNodeXPath)));
if (!xpath_nodeset.get()) {
completer->set_code(kErrorCodeOmahaResponseInvalid);
@@ -665,7 +664,7 @@
static const char* kPackageNodeXPath(
"/response/app/updatecheck/manifest/packages/package");
- scoped_ptr_malloc<xmlXPathObject, ScopedPtrXmlXPathObjectFree>
+ scoped_ptr<xmlXPathObject, ScopedPtrXmlXPathObjectFree>
xpath_nodeset(GetNodeSet(doc, ConstXMLStr(kPackageNodeXPath)));
if (!xpath_nodeset.get()) {
completer->set_code(kErrorCodeOmahaResponseInvalid);
@@ -720,7 +719,7 @@
"/response/app/updatecheck/manifest/actions/action");
// Get the manifest node where version is present.
- scoped_ptr_malloc<xmlXPathObject, ScopedPtrXmlXPathObjectFree>
+ scoped_ptr<xmlXPathObject, ScopedPtrXmlXPathObjectFree>
xpath_manifest_nodeset(GetNodeSet(doc, ConstXMLStr(kManifestNodeXPath)));
if (!xpath_manifest_nodeset.get()) {
completer->set_code(kErrorCodeOmahaResponseInvalid);
@@ -745,7 +744,7 @@
<< output_object->version;
// Grab the action nodes.
- scoped_ptr_malloc<xmlXPathObject, ScopedPtrXmlXPathObjectFree>
+ scoped_ptr<xmlXPathObject, ScopedPtrXmlXPathObjectFree>
xpath_action_nodeset(GetNodeSet(doc, ConstXMLStr(kActionNodeXPath)));
if (!xpath_action_nodeset.get()) {
completer->set_code(kErrorCodeOmahaResponseInvalid);
@@ -847,7 +846,7 @@
}
// parse our response and fill the fields in the output object
- scoped_ptr_malloc<xmlDoc, ScopedPtrXmlDocFree> doc(
+ scoped_ptr<xmlDoc, ScopedPtrXmlDocFree> doc(
xmlParseMemory(&response_buffer_[0], response_buffer_.size()));
if (!doc.get()) {
LOG(ERROR) << "Omaha response not valid XML";
@@ -1235,7 +1234,7 @@
// static
bool OmahaRequestAction::ParseInstallDate(xmlDoc* doc,
OmahaResponse* output_object) {
- scoped_ptr_malloc<xmlXPathObject, ScopedPtrXmlXPathObjectFree>
+ scoped_ptr<xmlXPathObject, ScopedPtrXmlXPathObjectFree>
xpath_nodeset(GetNodeSet(doc, ConstXMLStr("/response/daystart")));
if (xpath_nodeset.get() == NULL)