@@ -17,6 +17,8 @@ using namespace swift;
17
17
18
18
namespace {
19
19
struct BridgedDiagnosticImpl {
20
+ typedef llvm::MallocAllocator Allocator;
21
+
20
22
InFlightDiagnostic inFlight;
21
23
std::vector<StringRef> textBlobs;
22
24
@@ -31,8 +33,10 @@ struct BridgedDiagnosticImpl {
31
33
32
34
~BridgedDiagnosticImpl () {
33
35
inFlight.flush ();
36
+
37
+ Allocator allocator;
34
38
for (auto text : textBlobs) {
35
- free (( void *) text.data ());
39
+ allocator. Deallocate (text. data (), text.size ());
36
40
}
37
41
}
38
42
};
@@ -100,8 +104,8 @@ BridgedDiagnostic Diagnostic_create(BridgedDiagnosticEngine cDiags,
100
104
BridgedSourceLoc cLoc,
101
105
BridgedString cText) {
102
106
StringRef origText = convertString (cText);
103
- llvm::MallocAllocator mallocAlloc ;
104
- StringRef text = origText.copy (mallocAlloc );
107
+ BridgedDiagnosticImpl::Allocator alloc ;
108
+ StringRef text = origText.copy (alloc );
105
109
106
110
SourceLoc loc = convertSourceLoc (cLoc);
107
111
@@ -148,8 +152,8 @@ void Diagnostic_fixItReplace(BridgedDiagnostic cDiag,
148
152
SourceLoc endLoc = convertSourceLoc (cEndLoc);
149
153
150
154
StringRef origReplaceText = convertString (cReplaceText);
151
- llvm::MallocAllocator mallocAlloc ;
152
- StringRef replaceText = origReplaceText.copy (mallocAlloc );
155
+ BridgedDiagnosticImpl::Allocator alloc ;
156
+ StringRef replaceText = origReplaceText.copy (alloc );
153
157
154
158
BridgedDiagnosticImpl *diag = convertDiagnostic (cDiag);
155
159
diag->textBlobs .push_back (replaceText);
0 commit comments