@@ -28,17 +28,17 @@ class VersionInfoQuerier {
2828 }
2929 const kEnUsLanguageCode = '040904e4' ;
3030 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 >>();
3333 try {
3434 if (VerQueryValue (versionInfo, keyPath, valueAddress, length) == 0 ) {
3535 return null ;
3636 }
3737 return valueAddress.value.unpackString (length.value);
3838 } finally {
39- free (keyPath);
40- free (length);
41- free (valueAddress);
39+ calloc. free (keyPath);
40+ calloc. free (length);
41+ calloc. free (valueAddress);
4242 }
4343 }
4444}
@@ -54,7 +54,7 @@ class PathProviderWindows extends PathProviderPlatform {
5454 /// This is typically the same as the TMP environment variable.
5555 @override
5656 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 >();
5858 String path;
5959
6060 try {
@@ -82,7 +82,7 @@ class PathProviderWindows extends PathProviderPlatform {
8282
8383 return Future .value (path);
8484 } finally {
85- free (buffer);
85+ calloc. free (buffer);
8686 }
8787 }
8888
@@ -115,7 +115,7 @@ class PathProviderWindows extends PathProviderPlatform {
115115 /// folderID is a GUID that represents a specific known folder ID, drawn from
116116 /// [WindowsKnownFolder] .
117117 Future <String > getPath (String folderID) {
118- final pathPtrPtr = allocate <Pointer <Utf16 >>();
118+ final pathPtrPtr = calloc <Pointer <Utf16 >>();
119119 final Pointer <GUID > knownFolderID = calloc <GUID >()..ref.setGUID (folderID);
120120
121121 try {
@@ -135,8 +135,8 @@ class PathProviderWindows extends PathProviderPlatform {
135135 final path = pathPtrPtr.value.unpackString (MAX_PATH );
136136 return Future .value (path);
137137 } finally {
138- free (pathPtrPtr);
139- free (knownFolderID);
138+ calloc. free (pathPtrPtr);
139+ calloc. free (knownFolderID);
140140 }
141141 }
142142
@@ -155,8 +155,8 @@ class PathProviderWindows extends PathProviderPlatform {
155155 String ? productName;
156156
157157 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 >();
160160 Pointer <Uint8 >? infoBuffer;
161161 try {
162162 // Get the module name.
@@ -169,10 +169,10 @@ class PathProviderWindows extends PathProviderPlatform {
169169 // From that, load the VERSIONINFO resource
170170 int infoSize = GetFileVersionInfoSize (moduleNameBuffer, unused);
171171 if (infoSize != 0 ) {
172- infoBuffer = allocate <Uint8 >(count : infoSize);
172+ infoBuffer = calloc <Uint8 >(infoSize);
173173 if (GetFileVersionInfo (moduleNameBuffer, 0 , infoSize, infoBuffer) ==
174174 0 ) {
175- free (infoBuffer);
175+ calloc. free (infoBuffer);
176176 infoBuffer = null ;
177177 }
178178 }
@@ -191,10 +191,10 @@ class PathProviderWindows extends PathProviderPlatform {
191191 ? path.join (companyName, productName)
192192 : productName;
193193 } finally {
194- free (moduleNameBuffer);
195- free (unused);
194+ calloc. free (moduleNameBuffer);
195+ calloc. free (unused);
196196 if (infoBuffer != null ) {
197- free (infoBuffer);
197+ calloc. free (infoBuffer);
198198 }
199199 }
200200 }
0 commit comments