[experiments] Use proper delete for array deallocation (#37704)

Fixes: #37693

Closes #37704

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/37704 from grpc:eugeneo-delete-array 98e026c152
PiperOrigin-RevId: 677958660
pull/37790/head
Eugene Ostroukhov 2 months ago committed by Copybara-Service
parent e88ac072b7
commit 7f550b11b8
  1. 11
      src/core/lib/experiments/config.cc

@ -21,6 +21,7 @@
#include <map>
#include <string>
#include <utility>
#include <vector>
#include "absl/functional/any_invocable.h"
#include "absl/log/check.h"
@ -66,8 +67,8 @@ absl::AnyInvocable<bool(struct ExperimentMetadata)>* g_check_constraints_cb =
class TestExperiments {
public:
TestExperiments(const ExperimentMetadata* experiment_metadata,
size_t num_experiments) {
enabled_ = new bool[num_experiments];
size_t num_experiments)
: enabled_(num_experiments) {
for (size_t i = 0; i < num_experiments; i++) {
if (g_check_constraints_cb != nullptr) {
enabled_[i] = (*g_check_constraints_cb)(experiment_metadata[i]);
@ -91,12 +92,10 @@ class TestExperiments {
}
// Overloading [] operator to access elements in array style
bool operator[](int index) { return enabled_[index]; }
~TestExperiments() { delete enabled_; }
bool operator[](int index) const { return enabled_[index]; }
private:
bool* enabled_;
std::vector<bool> enabled_;
};
TestExperiments* g_test_experiments = nullptr;

Loading…
Cancel
Save