diff options
author | Chun-Min Chang <[email protected]> | 2021-07-27 11:22:59 -0700 |
---|---|---|
committer | Matthew Gregan <[email protected]> | 2021-07-28 09:29:48 +1200 |
commit | f4ef497bbe74cac2af30de74e2a80fba9c0888f0 (patch) | |
tree | 6c650e3b40bde3105648987bf070b878337a53d6 /src/cubeb_array_queue.h | |
parent | e1456788c48c5ed6b55bc107a7342d63f2a08413 (diff) | |
download | cubeb-f4ef497bbe74cac2af30de74e2a80fba9c0888f0.tar.gz cubeb-f4ef497bbe74cac2af30de74e2a80fba9c0888f0.zip |
Run .clang-format
Format all the code under `include` and `src` except those files under
`src/speex` with style setting in `.clang-format` file by the following
script:
```sh
FILE_LIST="$(find "include" "src" -not -path "src/speex/*" | grep -E ".*(\.cpp|\.c|\.h|\.hpp|\.hh)$")"
echo "Files found to format:\n---\n$FILE_LIST\n---"
clang-format --verbose -i $FILE_LIST
```
Diffstat (limited to 'src/cubeb_array_queue.h')
-rw-r--r-- | src/cubeb_array_queue.h | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/cubeb_array_queue.h b/src/cubeb_array_queue.h index a8ea4cd..d6d9581 100644 --- a/src/cubeb_array_queue.h +++ b/src/cubeb_array_queue.h @@ -16,8 +16,7 @@ extern "C" { #endif -typedef struct -{ +typedef struct { void ** buf; size_t num; size_t writePos; @@ -25,10 +24,11 @@ typedef struct pthread_mutex_t mutex; } array_queue; -array_queue * array_queue_create(size_t num) +array_queue * +array_queue_create(size_t num) { assert(num != 0); - array_queue * new_queue = (array_queue*)calloc(1, sizeof(array_queue)); + array_queue * new_queue = (array_queue *)calloc(1, sizeof(array_queue)); new_queue->buf = (void **)calloc(1, sizeof(void *) * num); new_queue->readPos = 0; new_queue->writePos = 0; @@ -39,7 +39,8 @@ array_queue * array_queue_create(size_t num) return new_queue; } -void array_queue_destroy(array_queue * aq) +void +array_queue_destroy(array_queue * aq) { assert(aq); @@ -48,14 +49,14 @@ void array_queue_destroy(array_queue * aq) free(aq); } -int array_queue_push(array_queue * aq, void * item) +int +array_queue_push(array_queue * aq, void * item) { assert(item); pthread_mutex_lock(&aq->mutex); int ret = -1; - if(aq->buf[aq->writePos % aq->num] == NULL) - { + if (aq->buf[aq->writePos % aq->num] == NULL) { aq->buf[aq->writePos % aq->num] = item; aq->writePos = (aq->writePos + 1) % aq->num; ret = 0; @@ -65,12 +66,12 @@ int array_queue_push(array_queue * aq, void * item) return ret; } -void* array_queue_pop(array_queue * aq) +void * +array_queue_pop(array_queue * aq) { pthread_mutex_lock(&aq->mutex); void * value = aq->buf[aq->readPos % aq->num]; - if(value) - { + if (value) { aq->buf[aq->readPos % aq->num] = NULL; aq->readPos = (aq->readPos + 1) % aq->num; } @@ -78,7 +79,8 @@ void* array_queue_pop(array_queue * aq) return value; } -size_t array_queue_get_size(array_queue * aq) +size_t +array_queue_get_size(array_queue * aq) { pthread_mutex_lock(&aq->mutex); ssize_t r = aq->writePos - aq->readPos; @@ -94,4 +96,4 @@ size_t array_queue_get_size(array_queue * aq) } #endif -#endif //CUBE_ARRAY_QUEUE_H +#endif // CUBE_ARRAY_QUEUE_H |