Browse Source

[3434] clarified clear() and added wipe()

Francis Dupont 11 years ago
parent
commit
cba839c48f
1 changed files with 8 additions and 1 deletions
  1. 8 1
      src/lib/util/buffer.h

+ 8 - 1
src/lib/util/buffer.h

@@ -417,8 +417,15 @@ public:
     /// \brief Clear buffer content.
     ///
     /// This method can be used to re-initialize and reuse the buffer without
-    /// constructing a new one.
+    /// constructing a new one. Note it must keep current content.
     void clear() { size_ = 0; }
+    /// \brief Wipe buffer content.
+    ///
+    /// This method is the destructive alternative to clear().
+    void wipe() {
+        memset(buffer_, 0, allocated_);
+        size_ = 0;
+    }
     /// \brief Write an unsigned 8-bit integer into the buffer.
     ///
     /// \param data The 8-bit integer to be written into the buffer.