Skip to content

Commit

Permalink
Fix find_callback in C API (fixes issue #187).
Browse files Browse the repository at this point in the history
  • Loading branch information
SpartanJ committed Nov 4, 2024
1 parent 3c5bf83 commit 8d46d1c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/efsw/FileWatcherCWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ class Watcher_CAPI : public efsw::FileWatchListener {
*/
static std::vector<Watcher_CAPI*> g_callbacks;

Watcher_CAPI* find_callback( efsw_watcher watcher, efsw_pfn_fileaction_callback fn ) {
Watcher_CAPI* find_callback( efsw_watcher watcher, efsw_pfn_fileaction_callback fn, void* param ) {
for ( std::vector<Watcher_CAPI*>::iterator i = g_callbacks.begin(); i != g_callbacks.end();
++i ) {
Watcher_CAPI* callback = *i;

if ( callback->mFn == fn && callback->mWatcher == watcher )
if ( callback->mFn == fn && callback->mWatcher == watcher && callback->mParam == param )
return *i;
}

Expand Down Expand Up @@ -84,7 +84,7 @@ efsw_watchid efsw_addwatch_withoptions(efsw_watcher watcher, const char* direct
efsw_pfn_fileaction_callback callback_fn, int recursive,
efsw_watcher_option *options, int options_number,
void* param) {
Watcher_CAPI* callback = find_callback( watcher, callback_fn );
Watcher_CAPI* callback = find_callback( watcher, callback_fn, param );

if ( callback == NULL ) {
callback = new Watcher_CAPI( watcher, callback_fn, param );
Expand Down

0 comments on commit 8d46d1c

Please sign in to comment.