MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_watcher_free

Function cbm_watcher_free

src/watcher/watcher.c:1120–1140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1118}
1119
1120void cbm_watcher_free(cbm_watcher_t *w) {
1121 if (!w) {
1122 return;
1123 }
1124 /* Safety net: ensure stopped is set before draining pending_free.
1125 * In production the caller should cbm_watcher_stop() + join first. */
1126 atomic_store(&w->stopped, 1);
1127 cbm_mutex_lock(&w->coordination_lock);
1128 cbm_mutex_lock(&w->projects_lock);
1129 cbm_ht_foreach(w->projects, free_state_entry, NULL);
1130 cbm_ht_free(w->projects);
1131 for (int i = 0; i < w->pending_free_count; i++) {
1132 state_free(w->pending_free[i]);
1133 }
1134 free(w->pending_free);
1135 cbm_mutex_unlock(&w->projects_lock);
1136 cbm_mutex_unlock(&w->coordination_lock);
1137 cbm_mutex_destroy(&w->projects_lock);
1138 cbm_mutex_destroy(&w->coordination_lock);
1139 free(w);
1140}
1141
1142void cbm_watcher_set_project_mutation_guard(cbm_watcher_t *w,
1143 cbm_watcher_project_mutation_begin_fn begin,

Calls 6

cbm_mutex_lockFunction · 0.85
cbm_ht_foreachFunction · 0.85
cbm_ht_freeFunction · 0.85
state_freeFunction · 0.85
cbm_mutex_unlockFunction · 0.85
cbm_mutex_destroyFunction · 0.85