@@ -59,6 +59,21 @@ class PublicKey {
59
59
// Disable the copy constructor, we're pointer based
60
60
PublicKey (const PublicKey& that) = delete ;
61
61
62
+ // Allow moves
63
+ PublicKey (PublicKey&& that) {
64
+ _key = that._key ;
65
+ that._key = nullptr ;
66
+ }
67
+
68
+ PublicKey& operator =(PublicKey&& that) {
69
+ if (this != &that) {
70
+ free (_key);
71
+ _key = that._key ;
72
+ that._key = nullptr ;
73
+ }
74
+ return *this ;
75
+ }
76
+
62
77
private:
63
78
brssl::public_key *_key;
64
79
};
@@ -87,6 +102,21 @@ class PrivateKey {
87
102
// Disable the copy constructor, we're pointer based
88
103
PrivateKey (const PrivateKey& that) = delete ;
89
104
105
+ // Allow moves
106
+ PrivateKey (PrivateKey&& that) {
107
+ _key = that._key ;
108
+ that._key = nullptr ;
109
+ }
110
+
111
+ PrivateKey& operator =(PrivateKey&& that) {
112
+ if (this != &that) {
113
+ free (_key);
114
+ _key = that._key ;
115
+ that._key = nullptr ;
116
+ }
117
+ return *this ;
118
+ }
119
+
90
120
private:
91
121
brssl::private_key *_key;
92
122
};
@@ -123,6 +153,30 @@ class X509List {
123
153
// Disable the copy constructor, we're pointer based
124
154
X509List (const X509List& that) = delete ;
125
155
156
+ // Allow moves
157
+ X509List (X509List&& that) {
158
+ _count = that._count ;
159
+ _cert = that._cert ;
160
+ _ta = that._ta ;
161
+ that._count = 0 ;
162
+ that._cert = nullptr ;
163
+ that._ta = nullptr ;
164
+ }
165
+
166
+ X509List& operator =(X509List&& that) {
167
+ if (this != &that) {
168
+ free (_cert);
169
+ free (_ta);
170
+ _count = that._count ;
171
+ _cert = that._cert ;
172
+ _ta = that._ta ;
173
+ that._count = 0 ;
174
+ that._cert = nullptr ;
175
+ that._ta = nullptr ;
176
+ }
177
+ return *this ;
178
+ }
179
+
126
180
private:
127
181
size_t _count;
128
182
br_x509_certificate *_cert;
@@ -170,6 +224,32 @@ class ServerSessions {
170
224
// Returns the number of sessions the cache can hold.
171
225
uint32_t size () { return _size; }
172
226
227
+ // Disable the copy constructor, we're pointer based
228
+ ServerSessions (const ServerSessions& that) = delete ;
229
+
230
+ // Allow moves
231
+ ServerSessions (ServerSessions&& that) {
232
+ _size = that._size ;
233
+ _store = that._store ;
234
+ _isDynamic = that._isDynamic ;
235
+ _cache = that._cache ;
236
+ that._size = 0 ;
237
+ that._store = nullptr ;
238
+ }
239
+
240
+ ServerSessions& operator =(ServerSessions&& that) {
241
+ if (this != &that) {
242
+ free (_store);
243
+ _size = that._size ;
244
+ _store = that._store ;
245
+ _isDynamic = that._isDynamic ;
246
+ _cache = that._cache ;
247
+ that._size = 0 ;
248
+ that._store = nullptr ;
249
+ }
250
+ return *this ;
251
+ }
252
+
173
253
private:
174
254
ServerSessions (ServerSession *sessions, uint32_t size, bool isDynamic);
175
255
0 commit comments