mirror of
https://github.com/openharmony/utils_native.git
synced 2026-07-21 01:25:42 -04:00
+3
-19
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user