ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtutil.h
(Generate patch)

Comparing rxvt-unicode/src/rxvtutil.h (file contents):
Revision 1.60 by sf-exg, Tue Oct 28 09:05:33 2014 UTC vs.
Revision 1.62 by sf-exg, Wed Nov 12 12:12:02 2014 UTC

1#ifndef RXVT_UTIL_H 1#ifndef RXVT_UTIL_H
2#define RXVT_UTIL_H 2#define RXVT_UTIL_H
3 3
4#include <new>
5#include <stdlib.h> 4#include <stdlib.h>
6#include <string.h> 5#include <string.h>
7#include "ecb.h" 6#include "ecb.h"
8#include "estl.h" 7#include "estl.h"
9 8
61{ 60{
62 void *operator new (size_t s); 61 void *operator new (size_t s);
63 void operator delete (void *p, size_t s); 62 void operator delete (void *p, size_t s);
64}; 63};
65 64
66// alas new/delete cannot be specified as inline in C++11 (see 17.6.4.6)
67void *operator new (size_t s) throw (std::bad_alloc);
68void operator delete (void *p) throw ();
69
70struct stringvec : simplevec<char *> 65struct stringvec : simplevec<char *>
71{ 66{
72 ~stringvec () 67 ~stringvec ()
73 { 68 {
74 for (char **c = begin (); c != end (); c++) 69 for (char **c = begin (); c != end (); c++)
91 T &operator [] (int i) { return * (T *) (& ((* (simplevec<void *> *)this)[i])); } 86 T &operator [] (int i) { return * (T *) (& ((* (simplevec<void *> *)this)[i])); }
92 const T &operator [] (int i) const { return * (const T *) (& ((* (const simplevec<void *> *)this)[i])); } 87 const T &operator [] (int i) const { return * (const T *) (& ((* (const simplevec<void *> *)this)[i])); }
93}; 88};
94#endif 89#endif
95 90
96template<typename T> 91typedef estl::scoped_array<char> auto_str;
97struct auto_ptr
98{
99 T *p;
100
101 auto_ptr () : p (0) { }
102
103 explicit
104 auto_ptr (T *a) : p (a) { }
105
106 auto_ptr (auto_ptr &a)
107 {
108 p = a.p;
109 a.p = 0;
110 }
111
112 template<typename A>
113 auto_ptr (auto_ptr<A> &a)
114 {
115 p = a.p;
116 a.p = 0;
117 }
118
119 ~auto_ptr ()
120 {
121 delete p;
122 }
123
124 void reset (T *a)
125 {
126 delete p;
127 p = a;
128 }
129
130 // void because it makes sense in our context
131 void operator =(auto_ptr &a)
132 {
133 reset (a.release ());
134 }
135
136 template<typename A>
137 void operator =(auto_ptr<A> &a)
138 {
139 reset (a.release ());
140 }
141
142 T *operator ->() const { return p; }
143 T &operator *() const { return *p; }
144
145 operator T *() { return p; }
146 T *get () const { return p; }
147
148 T *release()
149 {
150 T *r = p;
151 p = 0;
152 return r;
153 }
154};
155
156typedef auto_ptr<char> auto_str;
157 92
158#endif 93#endif
159 94

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines