Skip to content

Commit d576fa3

Browse files
committed
[Runtime] Replace use of C++ new with malloc()
1 parent 9eebee8 commit d576fa3

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

stdlib/public/runtime/ProtocolConformance.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -563,14 +563,19 @@ namespace {
563563
ConformanceLookupResult result)
564564
: Type(key.Type), Witness(result.witnessTable)
565565
{
566-
if (result.globalActorIsolationType) {
567-
ProtoOrStorage = new ExtendedStorage{
568-
key.Proto, result.globalActorIsolationType,
569-
result.globalActorIsolationWitnessTable
570-
};
571-
} else {
566+
if (!result.globalActorIsolationType) {
572567
ProtoOrStorage = key.Proto;
568+
return;
573569
}
570+
571+
// Allocate extended storage.
572+
void *memory = malloc(sizeof(ExtendedStorage));
573+
auto storage = new (memory) ExtendedStorage{
574+
key.Proto, result.globalActorIsolationType,
575+
result.globalActorIsolationWitnessTable
576+
};
577+
578+
ProtoOrStorage = storage;
574579
}
575580

576581
bool matchesKey(const ConformanceCacheKey &key) const {

0 commit comments

Comments
 (0)