gbranden pushed a commit to branch master
in repository groff.

commit cc1b835c6a3b37285e651caee9d2d8d866a0e73b
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Jun 19 03:21:10 2026 -0500

    src/libs/libgroff/string.cpp: Drop redundant code.
    
    * src/libs/libgroff/string.cpp (string::string): Drop redundant
      memset(3) calls; `salloc()` already ensures that the memory to which
      it returns a pointer is cleared.
---
 ChangeLog                    | 6 ++++++
 src/libs/libgroff/string.cpp | 5 -----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 036c3ef81..bbd0598ff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2026-06-19  G. Branden Robinson <[email protected]>
+
+       * src/libs/libgroff/string.cpp (string::string): Drop redundant
+       memset(3) calls; `salloc()` already ensures that the memory to
+       which it returns a pointer is cleared.
+
 2026-06-19  G. Branden Robinson <[email protected]>
 
        [libgroff]: Disable unused `string` functions.
diff --git a/src/libs/libgroff/string.cpp b/src/libs/libgroff/string.cpp
index f0b4746ef..720a391ae 100644
--- a/src/libs/libgroff/string.cpp
+++ b/src/libs/libgroff/string.cpp
@@ -133,7 +133,6 @@ string::string(const char *p, size_t n) : len(n)
 {
   ptr = salloc(n, &sz);
   assert(ptr != 0 /* nullptr */);
-  memset(ptr, 0, sz);
   if (n != 0)
     memcpy(ptr, p, n);
 }
@@ -149,8 +148,6 @@ string::string(const char *p)
     len = strlen(p);
     ptr = salloc(len, &sz);
     assert(ptr != 0 /* nullptr */);
-    if (len < sz)
-      memset(ptr, 0, sz);
     if (len != 0)
       memcpy(ptr, p, len);
   }
@@ -169,8 +166,6 @@ string::string(const string &s) : len(s.len)
 {
   ptr = salloc(len, &sz);
   assert(ptr != 0 /* nullptr */);
-  if (sz > 0)
-    memset(ptr, 0, sz);
   if (len != 0)
     memcpy(ptr, s.ptr, len);
 }

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to