@@ -47,12 +47,14 @@ class BufferRTOS : public BaseBuffer<T> {
47
47
~BufferRTOS () { end (); }
48
48
49
49
// / Re-Allocats the memory and the queue
50
- void resize (size_t size) {
50
+ bool resize (size_t size) {
51
+ bool result = true ;
51
52
if (current_size != size) {
52
53
end ();
53
54
current_size = size;
54
- setup ();
55
+ result = setup ();
55
56
}
57
+ return result;
56
58
}
57
59
58
60
void setReadMaxWait (TickType_t ticks) { readWait = ticks; }
@@ -167,17 +169,26 @@ class BufferRTOS : public BaseBuffer<T> {
167
169
if (current_size == 0 ) return true ;
168
170
169
171
// allocate data if necessary
172
+ int size = (current_size + 1 ) * sizeof (T);
170
173
if (p_data == nullptr ) {
171
- p_data = (uint8_t *)p_allocator->allocate ((current_size + 1 ) * sizeof (T));
174
+ p_data = (uint8_t *)p_allocator->allocate (size);
175
+ // check allocation
176
+ if (p_data == nullptr ) {
177
+ LOGE (" allocate falied for %d bytes" , size)
178
+ return false ;
179
+ }
172
180
}
173
- if (p_data == nullptr ) return false ;
181
+
174
182
175
183
// create stream buffer if necessary
176
184
if (xStreamBuffer == nullptr ) {
177
185
xStreamBuffer = xStreamBufferCreateStatic (current_size, trigger_level,
178
186
p_data, &static_stream_buffer);
179
187
}
180
- if (xStreamBuffer == nullptr ) return false ;
188
+ if (xStreamBuffer == nullptr ) {
189
+ LOGE (" xStreamBufferCreateStatic failed" );
190
+ return false ;
191
+ }
181
192
// make sure that the data is empty
182
193
reset ();
183
194
return true ;
0 commit comments