Skip to content

Commit 4335552

Browse files
committed
Fix small memory leak in WatcherWin32.
1 parent c57b51e commit 4335552

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/efsw/WatcherWin32.cpp

+3-6
Original file line numberDiff line numberDiff line change
@@ -215,17 +215,14 @@ void DestroyWatch( WatcherStructWin32* pWatch ) {
215215
CloseHandle( pWatch->Watch->DirHandle );
216216
efSAFE_DELETE_ARRAY( pWatch->Watch->DirName );
217217
efSAFE_DELETE( pWatch->Watch );
218+
efSAFE_DELETE( pWatch );
218219
}
219220
}
220221

221222
/// Starts monitoring a directory.
222223
WatcherStructWin32* CreateWatch( LPCWSTR szDirectory, bool recursive,
223224
DWORD bufferSize, DWORD notifyFilter, HANDLE iocp ) {
224-
WatcherStructWin32* tWatch;
225-
size_t ptrsize = sizeof( *tWatch );
226-
tWatch = static_cast<WatcherStructWin32*>(
227-
HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, ptrsize ) );
228-
225+
WatcherStructWin32* tWatch = new WatcherStructWin32();
229226
WatcherWin32* pWatch = new WatcherWin32(bufferSize);
230227
if (tWatch)
231228
tWatch->Watch = pWatch;
@@ -246,7 +243,7 @@ WatcherStructWin32* CreateWatch( LPCWSTR szDirectory, bool recursive,
246243

247244
CloseHandle( pWatch->DirHandle );
248245
efSAFE_DELETE( pWatch->Watch );
249-
HeapFree( GetProcessHeap(), 0, tWatch );
246+
efSAFE_DELETE( tWatch );
250247
return NULL;
251248
}
252249

0 commit comments

Comments
 (0)