From 572d272ebff0bf8d57704f34422e901cd8f8de3b Mon Sep 17 00:00:00 2001 From: Erik Boasson Date: Thu, 20 Jun 2019 18:35:03 +0200 Subject: [PATCH] Initialize common ddsi_sertopic with memset struct ddsi_sertopic will shortly change a little bit by the removal of two members that should never have been in it in the first place and that had to be initialized to 0. Relying on memset makes the source code independent of this difference. Signed-off-by: Erik Boasson --- rmw_cyclonedds_cpp/src/serdata.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rmw_cyclonedds_cpp/src/serdata.cpp b/rmw_cyclonedds_cpp/src/serdata.cpp index 32c91c2..f38d734 100644 --- a/rmw_cyclonedds_cpp/src/serdata.cpp +++ b/rmw_cyclonedds_cpp/src/serdata.cpp @@ -361,6 +361,7 @@ static std::string get_type_name (const char *type_support_identifier, void *typ struct sertopic_rmw *create_sertopic (const char *topicname, const char *type_support_identifier, void *type_support, bool is_request_header) { struct sertopic_rmw *st = new struct sertopic_rmw; + memset (st, 0, sizeof (struct ddsi_sertopic)); st->cpp_name = std::string (topicname); st->cpp_type_name = get_type_name (type_support_identifier, type_support); st->cpp_name_type_name = st->cpp_name + std::string (";") + std::string (st->cpp_type_name); @@ -371,8 +372,6 @@ struct sertopic_rmw *create_sertopic (const char *topicname, const char *type_su st->name = const_cast (st->cpp_name.c_str ()); st->type_name = const_cast (st->cpp_type_name.c_str ()); st->iid = ddsi_iid_gen (); - st->status_cb = nullptr; - st->status_cb_entity = nullptr; /* set by dds_create_topic_arbitrary */ ddsrt_atomic_st32 (&st->refc, 1); st->type_support.typesupport_identifier_ = type_support_identifier;