Switch to unified view

a/src/utils/refcntr.h b/src/utils/refcntr.h
...
...
5
template <class X> class RefCntr {
5
template <class X> class RefCntr {
6
    X   *rep;
6
    X   *rep;
7
    int *pcount;
7
    int *pcount;
8
public:
8
public:
9
    RefCntr() 
9
    RefCntr() 
10
  : rep(0), pcount(0) 
10
        : rep(0), pcount(0) 
11
    {}
11
    {}
12
    explicit RefCntr(X *pp) 
12
    explicit RefCntr(X *pp) 
13
  : rep(pp), pcount(new int(1)) 
13
        : rep(pp), pcount(new int(1)) 
14
    {}
14
    {}
15
    RefCntr(const RefCntr &r) 
15
    RefCntr(const RefCntr &r) 
16
  : rep(r.rep), pcount(r.pcount) 
16
        : rep(r.rep), pcount(r.pcount) 
17
    { 
17
    { 
18
  if (pcount)
18
        if (pcount)
19
      (*pcount)++;
19
            (*pcount)++;
20
    }
20
    }
21
    RefCntr& operator=(const RefCntr& r) 
21
    RefCntr& operator=(const RefCntr& r) 
22
    {
22
    {
23
  if (rep == r.rep) 
23
        if (rep == r.rep) 
24
      return *this;
24
            return *this;
25
  if (pcount && --(*pcount) == 0) {
25
        if (pcount && --(*pcount) == 0) {
26
      delete rep;
26
            delete rep;
27
      delete pcount;
27
            delete pcount;
28
  }
28
        }
29
  rep = r.rep;
29
        rep = r.rep;
30
  pcount = r.pcount;
30
        pcount = r.pcount;
31
  if (pcount)
31
        if (pcount)
32
      (*pcount)++;
32
            (*pcount)++;
33
  return  *this;
33
        return  *this;
34
    }
35
    void release()
36
    {
37
        if (pcount && --(*pcount) == 0) {
38
            delete rep;
39
            delete pcount;
40
        }
41
        rep = 0;
42
        pcount = 0;
34
    }
43
    }
35
    ~RefCntr() 
44
    ~RefCntr() 
36
    {
45
    {
37
  if (pcount && --(*pcount) == 0) {
46
        release();
38
      delete rep; 
39
      delete pcount; 
40
  }
41
    }
47
    }
42
    X *operator->() {return rep;}
48
    X *operator->() {return rep;}
43
    X *getptr() const {return rep;}
49
    X *getptr() const {return rep;}
44
    const X *getconstptr() const {return rep;}
50
    const X *getconstptr() const {return rep;}
45
    int getcnt() const {return pcount ? *pcount : 0;}
51
    int getcnt() const {return pcount ? *pcount : 0;}