Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dead string serialization code #41

Merged
merged 2 commits into from
Sep 27, 2019

Conversation

rotu
Copy link
Collaborator

@rotu rotu commented Sep 23, 2019

fix #40

@rotu rotu changed the title Remove dead string serialization code code Remove dead string serialization code Sep 24, 2019
@rotu rotu mentioned this pull request Sep 24, 2019
@eboasson
Copy link
Collaborator

@rotu looks good to me, the only thing is that cycser and cycprint have the same unused function. I'm not sure how to give you a patch to add to this PR other than by just copy-pasting it here.

diff --git a/rmw_cyclonedds_cpp/include/rmw_cyclonedds_cpp/serdes.hpp b/rmw_cyclonedds_cpp/include/rmw_cyclonedds_cpp/serdes.hpp
index 77f7d29..4cdb678 100755
--- a/rmw_cyclonedds_cpp/include/rmw_cyclonedds_cpp/serdes.hpp
+++ b/rmw_cyclonedds_cpp/include/rmw_cyclonedds_cpp/serdes.hpp
@@ -47,7 +47,6 @@ public:
   inline cycser & operator<<(uint64_t x) {serialize(x); return *this;}
   inline cycser & operator<<(float x) {serialize(x); return *this;}
   inline cycser & operator<<(double x) {serialize(x); return *this;}
-  inline cycser & operator<<(const char * x) {serialize(x); return *this;}
   inline cycser & operator<<(const std::string & x) {serialize(x); return *this;}
   inline cycser & operator<<(const std::wstring & x) {serialize(x); return *this;}
   template<class T>
@@ -80,14 +79,6 @@ public:
   {
     serialize(static_cast<unsigned char>(x));
   }
-  inline void serialize(const char * x)
-  {
-    size_t sz = strlen(x) + 1;
-    serialize(static_cast<uint32_t>(sz));
-    resize(off + sz);
-    memcpy(data() + off, x, sz);
-    off += sz;
-  }
   inline void serialize(const std::string & x)
   {
     size_t sz = x.size() + 1;
@@ -395,7 +386,6 @@ public:
   inline cycprint & operator>>(uint64_t & x) {print(x); return *this;}
   inline cycprint & operator>>(float & x) {print(x); return *this;}
   inline cycprint & operator>>(double & x) {print(x); return *this;}
-  inline cycprint & operator>>(char * & x) {print(x); return *this;}
   inline cycprint & operator>>(std::string & x) {print(x); return *this;}
   inline cycprint & operator>>(std::wstring & x) {print(x); return *this;}
   template<class T>
@@ -461,15 +451,6 @@ public:
     validate_size(sz, el_sz);
     return sz;
   }
-  inline void print(char * & x)
-  {
-    const uint32_t sz = get_len(sizeof(char));
-    validate_str(sz);
-    const int len = (sz == 0) ? 0 : (sz > INT32_MAX) ? INT32_MAX : static_cast<int>(sz - 1);
-    static_cast<void>(x);
-    prtf(&buf, &bufsize, "\"%*.*s\"", len, len, static_cast<const char *>(data + pos));
-    pos += sz;
-  }
   inline void print(std::string & x)
   {
     const uint32_t sz = get_len(sizeof(char));

@rotu
Copy link
Collaborator Author

rotu commented Sep 25, 2019

Thanks! good call

@eboasson
Copy link
Collaborator

Thanks @rotu!

@eboasson eboasson merged commit 1205ab5 into ros2:master Sep 27, 2019
@rotu rotu deleted the patch-1 branch April 6, 2020 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

memory leak? Does this malloc ever get freed?
2 participants