Skip to content

Commit e5a454c

Browse files
authored
Fix[MQB]: pass allocator correctly (#800)
Signed-off-by: Evgeny Malygin <emalygin@bloomberg.net>
1 parent 60f306d commit e5a454c

3 files changed

Lines changed: 25 additions & 17 deletions

File tree

src/groups/mqb/mqbc/mqbc_clusterdata.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ mqbc::ClusterDataIdentity clusterIdentity(const bslstl::StringRef& name,
7070
}
7171

7272
// Create and set description
73-
bdlma::LocalSequentialAllocator<256> localAllocator;
73+
bdlma::LocalSequentialAllocator<256> localAllocator(allocator);
7474
bmqu::MemOutStream os(&localAllocator);
7575
if (isRemote) {
7676
os << "ClusterProxy (" << name << ")";
@@ -79,10 +79,7 @@ mqbc::ClusterDataIdentity clusterIdentity(const bslstl::StringRef& name,
7979
os << "Cluster (" << name << ")";
8080
}
8181

82-
bsl::string description;
83-
description.assign(os.str().data(), os.str().length());
84-
85-
return mqbc::ClusterDataIdentity(name, description, identity);
82+
return mqbc::ClusterDataIdentity(name, os.str(), identity, allocator);
8683
}
8784

8885
} // close unnamed namespace

src/groups/mqb/mqbc/mqbc_clusterdata.h

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,22 @@ class ClusterDataIdentity {
8686
bmqp_ctrlmsg::ClientIdentity d_identity;
8787

8888
public:
89+
// TRAITS
90+
BSLMF_NESTED_TRAIT_DECLARATION(ClusterDataIdentity,
91+
bslma::UsesBslmaAllocator)
92+
8993
// CREATORS
9094

91-
/// Create a @bbref{mqbc::ClusterDataIdentity} with the specified `name`,
92-
/// `description` and `identity`.
93-
ClusterDataIdentity(const bsl::string& name,
94-
const bsl::string& description,
95-
const bmqp_ctrlmsg::ClientIdentity& identity);
95+
/// Create a @bbref{mqbc::ClusterDataIdentity}.
96+
/// @param name The cluster name.
97+
/// @param description The cluster description.
98+
/// @param identity The cluster identity.
99+
/// @param allocator Allocator to use, or use the default allocator if it
100+
/// is null.
101+
explicit ClusterDataIdentity(const bslstl::StringRef& name,
102+
const bslstl::StringRef& description,
103+
const bmqp_ctrlmsg::ClientIdentity& identity,
104+
bslma::Allocator* allocator = 0);
96105

97106
// ACCESSORS
98107

@@ -303,12 +312,13 @@ class ClusterData {
303312

304313
// CREATORS
305314
inline ClusterDataIdentity::ClusterDataIdentity(
306-
const bsl::string& name,
307-
const bsl::string& description,
308-
const bmqp_ctrlmsg::ClientIdentity& identity)
309-
: d_name(name)
310-
, d_description(description)
311-
, d_identity(identity)
315+
const bslstl::StringRef& name,
316+
const bslstl::StringRef& description,
317+
const bmqp_ctrlmsg::ClientIdentity& identity,
318+
bslma::Allocator* allocator)
319+
: d_name(name, allocator)
320+
, d_description(description, allocator)
321+
, d_identity(identity, allocator)
312322
{
313323
// NOTHING
314324
}

src/groups/mqb/mqbstat/mqbstat_clusterstats.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@ void ClusterStats::initialize(const bsl::string& name,
251251
bsl::shared_ptr<bmqst::StatContext>(
252252
d_statContext_mp->addSubcontext(
253253
bmqst::StatContextConfiguration(partitionName,
254-
&localAllocator))));
254+
&localAllocator)),
255+
allocator));
255256
setNodeRoleForPartition(pId, PrimaryStatus::e_UNKNOWN);
256257
}
257258
}

0 commit comments

Comments
 (0)