Skip to content

Commit

Permalink
modify
Browse files Browse the repository at this point in the history
  • Loading branch information
joonhaengHeo committed Apr 14, 2023
1 parent 3619342 commit c97da79
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/darwin/Framework/CHIP/MTRBaseDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,13 @@ - (void)readAttributePaths:(NSArray<MTRAttributeRequestPath *> * _Nullable)attri
size_t count = 0;
eventPathParamsList
= static_cast<EventPathParams *>(Platform::MemoryCalloc([events count], sizeof(EventPathParams)));
VerifyOrReturnError(eventPathParamsList != nullptr, CHIP_ERROR_NO_MEMORY);
if (eventPathParamsList == nullptr) {
if (attributePathParamsList != nullptr) {
Platform::MemoryFree(attributePathParamsList);
attributePathParamsList = nullptr;
}
return CHIP_ERROR_NO_MEMORY;
}
for (MTREventRequestPath * event in events) {
[event convertToEventPathParams:eventPathParamsList[count++]];
}
Expand Down Expand Up @@ -1396,11 +1402,9 @@ - (void)subscribeToAttributePaths:(NSArray<MTRAttributeRequestPath *> * _Nullabl
container.pathParams = static_cast<AttributePathParams *>(
Platform::MemoryCalloc([attributes count], sizeof(AttributePathParams)));
if (container.pathParams == nullptr) {
if (reportHandler) {
dispatch_async(queue, ^{
reportHandler(nil, [MTRError errorForCHIPErrorCode:CHIP_ERROR_NO_MEMORY]);
});
}
dispatch_async(queue, ^{
reportHandler(nil, [MTRError errorForCHIPErrorCode:CHIP_ERROR_NO_MEMORY]);
});
return;
}
for (MTRAttributeRequestPath * attribute in attributes) {
Expand All @@ -1412,11 +1416,9 @@ - (void)subscribeToAttributePaths:(NSArray<MTRAttributeRequestPath *> * _Nullabl
container.eventPathParams
= static_cast<EventPathParams *>(Platform::MemoryCalloc([events count], sizeof(EventPathParams)));
if (container.eventPathParams == nullptr) {
if (reportHandler) {
dispatch_async(queue, ^{
reportHandler(nil, [MTRError errorForCHIPErrorCode:CHIP_ERROR_NO_MEMORY]);
});
}
dispatch_async(queue, ^{
reportHandler(nil, [MTRError errorForCHIPErrorCode:CHIP_ERROR_NO_MEMORY]);
});
return;
}
for (MTREventRequestPath * event in events) {
Expand Down

0 comments on commit c97da79

Please sign in to comment.