Skip to content

Commit b324dec

Browse files
committed
Update formatting
1 parent 4aab817 commit b324dec

21 files changed

+2558
-25
lines changed

cores/esp32/cbuf.cpp

+48-25
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,57 @@
2222
#include "esp32-hal-log.h"
2323

2424
#if CONFIG_DISABLE_HAL_LOCKS
25-
#define CBUF_MUTEX_CREATE()
26-
#define CBUF_MUTEX_LOCK()
27-
#define CBUF_MUTEX_UNLOCK()
28-
#define CBUF_MUTEX_DELETE()
25+
#define CBUF_MUTEX_CREATE()
26+
#define CBUF_MUTEX_LOCK()
27+
#define CBUF_MUTEX_UNLOCK()
28+
#define CBUF_MUTEX_DELETE()
2929
#else
30-
#define CBUF_MUTEX_CREATE() \
31-
if (_lock == NULL) { \
32-
_lock = xSemaphoreCreateMutex(); \
33-
if (_lock == NULL) { \
34-
log_e("failed to create mutex"); \
35-
} \
36-
}
37-
#define CBUF_MUTEX_LOCK() \
38-
if (_lock != NULL) { \
39-
xSemaphoreTakeRecursive(_lock, portMAX_DELAY); \
40-
}
41-
#define CBUF_MUTEX_UNLOCK() \
42-
if (_lock != NULL) { \
43-
xSemaphoreGiveRecursive(_lock); \
44-
}
45-
#define CBUF_MUTEX_DELETE() \
46-
if (_lock != NULL) { \
47-
SemaphoreHandle_t l = _lock; \
48-
_lock = NULL; \
49-
vSemaphoreDelete(l); \
50-
}
30+
#define CBUF_MUTEX_CREATE() \
31+
if (_lock == NULL) { \
32+
_lock = xSemaphoreCreateMutex(); \
33+
if (_lock == NULL) { \
34+
log_e("failed to create mutex"); \
35+
} \
36+
}
37+
#define CBUF_MUTEX_LOCK() \
38+
if (_lock != NULL) { \
39+
xSemaphoreTakeRecursive(_lock, portMAX_DELAY); \
40+
}
41+
#define CBUF_MUTEX_UNLOCK() \
42+
if (_lock != NULL) { \
43+
xSemaphoreGiveRecursive(_lock); \
44+
}
45+
#define CBUF_MUTEX_DELETE() \
46+
if (_lock != NULL) { \
47+
SemaphoreHandle_t l = _lock; \
48+
_lock = NULL; \
49+
vSemaphoreDelete(l); \
50+
}
5151
#endif
5252

53+
cbuf::cbuf(size_t size)
54+
: next(NULL)
55+
, has_peek(false)
56+
, peek_byte(0)
57+
, _buf(xRingbufferCreate(size, RINGBUF_TYPE_BYTEBUF)) {
58+
if (_buf == NULL) {
59+
log_e("failed to allocate ring buffer");
60+
}
61+
CBUF_MUTEX_CREATE();
62+
}
63+
64+
cbuf::~cbuf() {
65+
CBUF_MUTEX_LOCK();
66+
if (_buf != NULL) {
67+
RingbufHandle_t b = _buf;
68+
_buf = NULL;
69+
vRingbufferDelete(b);
70+
}
71+
CBUF_MUTEX_UNLOCK();
72+
CBUF_MUTEX_DELETE();
73+
}
74+
75+
5376
cbuf::cbuf(size_t size) : next(NULL), has_peek(false), peek_byte(0), _buf(xRingbufferCreate(size, RINGBUF_TYPE_BYTEBUF)) {
5477
if (_buf == NULL) {
5578
log_e("failed to allocate ring buffer");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"requests":[{"kind":"cache","version":2},{"kind":"cmakeFiles","version":1},{"kind":"codemodel","version":2},{"kind":"toolchains","version":1}]}

0 commit comments

Comments
 (0)