Bug 823427 - Remove unnecessary buffer in ObexBase.cpp, r=gyeh, r=dholbert
authorEric Chou <echou@mozilla.com>
Fri, 21 Dec 2012 19:03:42 +0800
changeset 125867 c4bbe142937e281324c2bf1fd49d3559faed4528
parent 125866 c55e10ab852dba03188f9b93ff35c1d6309f691f
child 125868 44b06d49ffc6414b8305c114fb756da222b9efa6
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgyeh, dholbert
bugs823427
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 823427 - Remove unnecessary buffer in ObexBase.cpp, r=gyeh, r=dholbert
dom/bluetooth/ObexBase.cpp
dom/bluetooth/ObexBase.h
--- a/dom/bluetooth/ObexBase.cpp
+++ b/dom/bluetooth/ObexBase.cpp
@@ -110,18 +110,15 @@ ParseHeaders(const uint8_t* aHeaderStart
         break;
 
       case 0x03:
         // 4 byte quantity
         contentLength = 4;
         break;
     }
 
-    uint8_t* content = new uint8_t[contentLength];
-    memcpy(content, ptr, contentLength);
-    aRetHandlerSet->AddHeader(new ObexHeader(headerId, contentLength, content));
-    delete [] content;
+    aRetHandlerSet->AddHeader(new ObexHeader(headerId, contentLength, ptr));
 
     ptr += contentLength;
   }
 }
 
 END_BLUETOOTH_NAMESPACE
--- a/dom/bluetooth/ObexBase.h
+++ b/dom/bluetooth/ObexBase.h
@@ -99,17 +99,17 @@ enum ObexResponseCode {
   HttpVersionNotSupported = 0xD5,
 
   DatabaseFull = 0xE0,
   DatabaseLocked = 0xE1,
 };
 
 class ObexHeader {
 public:
-  ObexHeader(ObexHeaderId aId, int aDataLength, uint8_t* aData)
+  ObexHeader(ObexHeaderId aId, int aDataLength, const uint8_t* aData)
     : mId(aId)
     , mDataLength(aDataLength)
     , mData(nullptr)
   {
     mData = new uint8_t[mDataLength];
     memcpy(mData, aData, aDataLength);
   }