@@ -28,17 +28,17 @@ class VersionInfoQuerier {
28
28
}
29
29
const kEnUsLanguageCode = '040904e4' ;
30
30
final keyPath = TEXT ('\\ StringFileInfo\\ $kEnUsLanguageCode \\ $key ' );
31
- final length = allocate <Uint32 >();
32
- final valueAddress = allocate <Pointer <Utf16 >>();
31
+ final length = calloc <Uint32 >();
32
+ final valueAddress = calloc <Pointer <Utf16 >>();
33
33
try {
34
34
if (VerQueryValue (versionInfo, keyPath, valueAddress, length) == 0 ) {
35
35
return null ;
36
36
}
37
37
return valueAddress.value.unpackString (length.value);
38
38
} finally {
39
- free (keyPath);
40
- free (length);
41
- free (valueAddress);
39
+ calloc. free (keyPath);
40
+ calloc. free (length);
41
+ calloc. free (valueAddress);
42
42
}
43
43
}
44
44
}
@@ -54,7 +54,7 @@ class PathProviderWindows extends PathProviderPlatform {
54
54
/// This is typically the same as the TMP environment variable.
55
55
@override
56
56
Future <String ?> getTemporaryPath () async {
57
- final buffer = allocate <Uint16 >(count : MAX_PATH + 1 ).cast <Utf16 >();
57
+ final buffer = calloc <Uint16 >(MAX_PATH + 1 ).cast <Utf16 >();
58
58
String path;
59
59
60
60
try {
@@ -82,7 +82,7 @@ class PathProviderWindows extends PathProviderPlatform {
82
82
83
83
return Future .value (path);
84
84
} finally {
85
- free (buffer);
85
+ calloc. free (buffer);
86
86
}
87
87
}
88
88
@@ -115,7 +115,7 @@ class PathProviderWindows extends PathProviderPlatform {
115
115
/// folderID is a GUID that represents a specific known folder ID, drawn from
116
116
/// [WindowsKnownFolder] .
117
117
Future <String > getPath (String folderID) {
118
- final pathPtrPtr = allocate <Pointer <Utf16 >>();
118
+ final pathPtrPtr = calloc <Pointer <Utf16 >>();
119
119
final Pointer <GUID > knownFolderID = calloc <GUID >()..ref.setGUID (folderID);
120
120
121
121
try {
@@ -135,8 +135,8 @@ class PathProviderWindows extends PathProviderPlatform {
135
135
final path = pathPtrPtr.value.unpackString (MAX_PATH );
136
136
return Future .value (path);
137
137
} finally {
138
- free (pathPtrPtr);
139
- free (knownFolderID);
138
+ calloc. free (pathPtrPtr);
139
+ calloc. free (knownFolderID);
140
140
}
141
141
}
142
142
@@ -155,8 +155,8 @@ class PathProviderWindows extends PathProviderPlatform {
155
155
String ? productName;
156
156
157
157
final Pointer <Utf16 > moduleNameBuffer =
158
- allocate <Uint16 >(count : MAX_PATH + 1 ).cast <Utf16 >();
159
- final Pointer <Uint32 > unused = allocate <Uint32 >();
158
+ calloc <Uint16 >(MAX_PATH + 1 ).cast <Utf16 >();
159
+ final Pointer <Uint32 > unused = calloc <Uint32 >();
160
160
Pointer <Uint8 >? infoBuffer;
161
161
try {
162
162
// Get the module name.
@@ -169,10 +169,10 @@ class PathProviderWindows extends PathProviderPlatform {
169
169
// From that, load the VERSIONINFO resource
170
170
int infoSize = GetFileVersionInfoSize (moduleNameBuffer, unused);
171
171
if (infoSize != 0 ) {
172
- infoBuffer = allocate <Uint8 >(count : infoSize);
172
+ infoBuffer = calloc <Uint8 >(infoSize);
173
173
if (GetFileVersionInfo (moduleNameBuffer, 0 , infoSize, infoBuffer) ==
174
174
0 ) {
175
- free (infoBuffer);
175
+ calloc. free (infoBuffer);
176
176
infoBuffer = null ;
177
177
}
178
178
}
@@ -191,10 +191,10 @@ class PathProviderWindows extends PathProviderPlatform {
191
191
? path.join (companyName, productName)
192
192
: productName;
193
193
} finally {
194
- free (moduleNameBuffer);
195
- free (unused);
194
+ calloc. free (moduleNameBuffer);
195
+ calloc. free (unused);
196
196
if (infoBuffer != null ) {
197
- free (infoBuffer);
197
+ calloc. free (infoBuffer);
198
198
}
199
199
}
200
200
}
0 commit comments