Skip to content

Commit

Permalink
Merge branch 'master' into modernize
Browse files Browse the repository at this point in the history
  • Loading branch information
SpartanJ committed Aug 4, 2024
2 parents 095f368 + 621939d commit d98a5f7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/efsw/FileWatcherWin32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ void FileWatcherWin32::run() {
break;
} else {
Lock lock( mWatchesLock );
WatchCallback( numOfBytes, ov );
if (mWatches.find( (WatcherStructWin32*)ov ) != mWatches.end())
WatchCallback( numOfBytes, ov );
}
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/efsw/FileWatcherWin32.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <efsw/WatcherWin32.hpp>
#include <map>
#include <set>
#include <unordered_set>
#include <vector>

namespace efsw {
Expand All @@ -17,7 +17,7 @@ namespace efsw {
class FileWatcherWin32 : public FileWatcherImpl {
public:
/// type for a map from WatchID to WatcherWin32 pointer
typedef std::set<WatcherStructWin32*> Watches;
typedef std::unordered_set<WatcherStructWin32*> Watches;

FileWatcherWin32( FileWatcher* parent );

Expand Down
9 changes: 3 additions & 6 deletions src/efsw/WatcherWin32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,14 @@ void DestroyWatch( WatcherStructWin32* pWatch ) {
CloseHandle( pWatch->Watch->DirHandle );
efSAFE_DELETE_ARRAY( pWatch->Watch->DirName );
efSAFE_DELETE( pWatch->Watch );
efSAFE_DELETE( pWatch );
}
}

/// Starts monitoring a directory.
WatcherStructWin32* CreateWatch( LPCWSTR szDirectory, bool recursive,
DWORD bufferSize, DWORD notifyFilter, HANDLE iocp ) {
WatcherStructWin32* tWatch;
size_t ptrsize = sizeof( *tWatch );
tWatch = static_cast<WatcherStructWin32*>(
HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, ptrsize ) );

WatcherStructWin32* tWatch = new WatcherStructWin32();
WatcherWin32* pWatch = new WatcherWin32(bufferSize);
if (tWatch)
tWatch->Watch = pWatch;
Expand All @@ -246,7 +243,7 @@ WatcherStructWin32* CreateWatch( LPCWSTR szDirectory, bool recursive,

CloseHandle( pWatch->DirHandle );
efSAFE_DELETE( pWatch->Watch );
HeapFree( GetProcessHeap(), 0, tWatch );
efSAFE_DELETE( tWatch );
return NULL;
}

Expand Down

0 comments on commit d98a5f7

Please sign in to comment.