~ubuntu-branches/ubuntu/quantal/ceph/quantal

« back to all changes in this revision

Viewing changes to src/common/buffer.cc

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-07-16 09:56:24 UTC
  • mfrom: (0.3.11)
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: package-import@ubuntu.com-20120716095624-azr2w4hbhei1rxmx
Tags: upstream-0.48
ImportĀ upstreamĀ versionĀ 0.48

Show diffs side-by-side

added added

removed removed

Lines of Context:
88
88
  class buffer::raw_malloc : public buffer::raw {
89
89
  public:
90
90
    raw_malloc(unsigned l) : raw(l) {
91
 
      if (len)
 
91
      if (len) {
92
92
        data = (char *)malloc(len);
93
 
      else
 
93
        if (!data)
 
94
          throw bad_alloc();
 
95
      } else {
94
96
        data = 0;
 
97
      }
95
98
      inc_total_alloc(len);
96
99
      bdout << "raw_malloc " << this << " alloc " << (void *)data << " " << l << " " << buffer::get_total_alloc() << bendl;
97
100
    }
378
381
    return 0;
379
382
  }
380
383
 
 
384
  bool buffer::ptr::is_zero() const
 
385
  {
 
386
    const char *data = c_str();
 
387
    for (size_t p = 0; p < _len; p++) {
 
388
      if (data[p] != 0) {
 
389
        return false;
 
390
      }
 
391
    }
 
392
    return true;
 
393
  }
 
394
 
381
395
  void buffer::ptr::append(char c)
382
396
  {
383
397
    assert(_raw);
695
709
    return true;
696
710
  }
697
711
 
 
712
  bool buffer::list::is_zero() const {
 
713
    for (std::list<ptr>::const_iterator it = _buffers.begin();
 
714
         it != _buffers.end();
 
715
         it++) {
 
716
      if (!it->is_zero()) {
 
717
        return false;
 
718
      }
 
719
    }
 
720
    return true;
 
721
  }
 
722
 
698
723
  void buffer::list::zero()
699
724
  {
700
725
    for (std::list<ptr>::iterator it = _buffers.begin();