!84 回退对parcel下realloc的修改

Merge pull request !84 from giteeHYC/master
This commit is contained in:
openharmony_ci
2022-05-05 09:14:44 +00:00
committed by Gitee
+3 -19
View File
@@ -13,10 +13,9 @@
* limitations under the License.
*/
#include <malloc.h>
#include "parcel.h"
#include "securec.h"
#include "utils_log.h"
#include "parcel.h"
namespace OHOS {
@@ -581,7 +580,7 @@ bool Parcel::EnsureObjectsCapacity()
size_t newCapacity = ((objectsCapacity_ + NEW_CAPACITY_ADD) * NEW_CAPACITY_MULTI) / NEW_CAPACITY_DIV;
size_t newBytes = newCapacity * sizeof(binder_size_t);
void *newOffsets = allocator_->Realloc(objectOffsets_, newBytes);
void *newOffsets = realloc(objectOffsets_, newBytes);
if (newOffsets == nullptr) {
return false;
}
@@ -1132,22 +1131,7 @@ void DefaultAllocator::Dealloc(void *data)
void *DefaultAllocator::Realloc(void *data, size_t newSize)
{
if (newSize != 0) {
// newSize checked before Realloc.
void *newData = malloc(newSize);
if (newData != nullptr) {
if (data == nullptr) {
return newData;
}
if (memcpy_s(newData, newSize, data, malloc_usable_size(data)) == EOK) {
free(data);
return newData;
}
free(newData);
}
}
UTILS_LOGW("Realloc failed! newSize = %{public}zu", newSize);
return nullptr;
return realloc(data, newSize);
}
template <typename T1, typename T2>