@@ -20,6 +20,7 @@ using namespace std;
2020
2121static string notify_oid_prefix = " notify" ;
2222
23+ RGWSI_Notify::RGWSI_Notify (CephContext *cct) : RGWServiceInstance(cct) {}
2324RGWSI_Notify::~RGWSI_Notify ()
2425{
2526 shutdown ();
@@ -207,12 +208,12 @@ int RGWSI_Notify::init_watch(const DoutPrefixProvider *dpp, optional_yield y)
207208 if (num_watchers <= 0 )
208209 num_watchers = 1 ;
209210
210- watchers = new RGWWatcher *[num_watchers];
211-
212211 int error = 0 ;
213212
214213 notify_objs.resize (num_watchers);
215214
215+ watchers.reserve (num_watchers);
216+
216217 for (int i=0 ; i < num_watchers; i++) {
217218 string notify_oid;
218219
@@ -239,19 +240,18 @@ int RGWSI_Notify::init_watch(const DoutPrefixProvider *dpp, optional_yield y)
239240 return r;
240241 }
241242
242- RGWWatcher *watcher = new RGWWatcher (cct, this , i, notify_obj);
243- watchers[i] = watcher;
243+ auto & watcher = watchers.emplace_back (cct, this , i, notify_obj);
244244
245- r = watcher-> register_watch_async ();
245+ r = watcher. register_watch_async ();
246246 if (r < 0 ) {
247247 ldpp_dout (dpp, 0 ) << " WARNING: register_watch_aio() returned " << r << dendl;
248248 error = r;
249249 continue ;
250250 }
251251 }
252252
253- for (int i = 0 ; i < num_watchers; ++i ) {
254- int r = watchers[i]-> register_watch_finish ();
253+ for (auto & watcher : watchers ) {
254+ int r = watcher. register_watch_finish ();
255255 if (r < 0 ) {
256256 ldpp_dout (dpp, 0 ) << " WARNING: async watch returned " << r << dendl;
257257 error = r;
@@ -268,13 +268,10 @@ int RGWSI_Notify::init_watch(const DoutPrefixProvider *dpp, optional_yield y)
268268void RGWSI_Notify::finalize_watch ()
269269{
270270 for (int i = 0 ; i < num_watchers; i++) {
271- RGWWatcher *watcher = watchers[i];
272271 if (watchers_set.find (i) != watchers_set.end ())
273- watcher->unregister_watch ();
274- delete watcher;
272+ watchers[i].unregister_watch ();
275273 }
276-
277- delete[] watchers;
274+ watchers.clear ();
278275}
279276
280277int RGWSI_Notify::do_start (optional_yield y, const DoutPrefixProvider *dpp)
0 commit comments