]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
buffer: Move functions touching buffer::raw internals into buffer.cc
authorTommi Virtanen <tommi.virtanen@dreamhost.com>
Wed, 6 Apr 2011 20:53:25 +0000 (13:53 -0700)
committerTommi Virtanen <tommi.virtanen@dreamhost.com>
Thu, 7 Apr 2011 17:53:19 +0000 (10:53 -0700)
Signed-off-by: Tommi Virtanen <tommi.virtanen@dreamhost.com>
src/common/buffer.cc
src/include/buffer.h

index fec057f9b20a219f9f4141fae646cb21bbc1fc36..9869f28a6384b094fd89ef14ab90fe25b08889b2 100644 (file)
@@ -147,6 +147,36 @@ bool buffer_track_alloc = true;
     }
   }
 
+  bool buffer::ptr::at_buffer_tail() const { return _off + _len == _raw->len; }
+
+  const char *buffer::ptr::c_str() const { assert(_raw); return _raw->data + _off; }
+  char *buffer::ptr::c_str() { assert(_raw); return _raw->data + _off; }
+  unsigned buffer::ptr::unused_tail_length() const {
+    if (_raw)
+      return _raw->len - (_off+_len);
+    else
+      return 0;
+  }
+  const char& buffer::ptr::operator[](unsigned n) const {
+    assert(_raw);
+    assert(n < _len);
+    return _raw->data[_off + n];
+  }
+  char& buffer::ptr::operator[](unsigned n) {
+    assert(_raw);
+    assert(n < _len);
+    return _raw->data[_off + n];
+  }
+
+  const char *buffer::ptr::raw_c_str() const { assert(_raw); return _raw->data; }
+  unsigned buffer::ptr::raw_length() const { assert(_raw); return _raw->len; }
+  int buffer::ptr::raw_nref() const { assert(_raw); return _raw->nref.read(); }
+
+  unsigned buffer::ptr::wasted() {
+    assert(_raw);
+    return _raw->len - _len;
+  }
+
 void buffer::list::encode_base64(buffer::list& o)
 {
   bufferptr bp(length() * 4 / 3 + 3);
index 989ee3cf851c4e294341294127adc8d21c35a332..100ee71b8f133f7310bc44105abf16d1ccd54568 100644 (file)
@@ -348,39 +348,26 @@ public:
 
     // misc
     bool at_buffer_head() const { return _off == 0; }
-    bool at_buffer_tail() const { return _off + _len == _raw->len; }
+    bool at_buffer_tail() const;
 
     bool is_page_aligned() const { return ((long)c_str() & ~PAGE_MASK) == 0; }
     bool is_n_page_sized() const { return (length() & ~PAGE_MASK) == 0; }
 
     // accessors
     raw *get_raw() const { return _raw; }
-    const char *c_str() const { assert(_raw); return _raw->data + _off; }
-    char *c_str() { assert(_raw); return _raw->data + _off; }
+    const char *c_str() const;
+    char *c_str();
     unsigned length() const { return _len; }
     unsigned offset() const { return _off; }
     unsigned start() const { return _off; }
     unsigned end() const { return _off + _len; }
-    unsigned unused_tail_length() const { 
-      if (_raw)
-       return _raw->len - (_off+_len); 
-      else
-       return 0;
-    }
-    const char& operator[](unsigned n) const { 
-      assert(_raw); 
-      assert(n < _len);
-      return _raw->data[_off + n];
-    }
-    char& operator[](unsigned n) { 
-      assert(_raw); 
-      assert(n < _len);
-      return _raw->data[_off + n];
-    }
+    unsigned unused_tail_length() const;
+    const char& operator[](unsigned n) const;
+    char& operator[](unsigned n);
 
-    const char *raw_c_str() const { assert(_raw); return _raw->data; }
-    unsigned raw_length() const { assert(_raw); return _raw->len; }
-    int raw_nref() const { assert(_raw); return _raw->nref.read(); }
+    const char *raw_c_str() const;
+    unsigned raw_length() const;
+    int raw_nref() const;
 
     void copy_out(unsigned o, unsigned l, char *dest) const {
       assert(_raw);
@@ -389,10 +376,7 @@ public:
       memcpy(dest, c_str()+o, l);
     }
 
-    unsigned wasted() {
-      assert(_raw);
-      return _raw->len - _len;
-    }
+    unsigned wasted();
 
     int cmp(const ptr& o) {
       int l = _len < o._len ? _len : o._len;