diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-01-28 21:30:39 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-01-30 23:35:50 +0000 |
commit | 92ffad1a72bc8c422426d52ac408bd71242dd047 (patch) | |
tree | f592f353068dd2043525dd2cc04d6124a4ed4bc4 /toxav/ring_buffer.c | |
parent | 623e9ac331df7323660e21c8a2226523a5ee713b (diff) |
Use nullptr as NULL pointer constant instead of NULL or 0.
This changes only code, no string literals or comments.
Diffstat (limited to 'toxav/ring_buffer.c')
-rw-r--r-- | toxav/ring_buffer.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/toxav/ring_buffer.c b/toxav/ring_buffer.c index c60c21f2..d3f013c6 100644 --- a/toxav/ring_buffer.c +++ b/toxav/ring_buffer.c | |||
@@ -21,6 +21,8 @@ | |||
21 | */ | 21 | */ |
22 | #include "ring_buffer.h" | 22 | #include "ring_buffer.h" |
23 | 23 | ||
24 | #include "../toxcore/ccompat.h" | ||
25 | |||
24 | #include <stdlib.h> | 26 | #include <stdlib.h> |
25 | 27 | ||
26 | struct RingBuffer { | 28 | struct RingBuffer { |
@@ -46,7 +48,7 @@ bool rb_empty(const RingBuffer *b) | |||
46 | */ | 48 | */ |
47 | void *rb_write(RingBuffer *b, void *p) | 49 | void *rb_write(RingBuffer *b, void *p) |
48 | { | 50 | { |
49 | void *rc = NULL; | 51 | void *rc = nullptr; |
50 | 52 | ||
51 | if ((b->end + 1) % b->size == b->start) { /* full */ | 53 | if ((b->end + 1) % b->size == b->start) { /* full */ |
52 | rc = b->data[b->start]; | 54 | rc = b->data[b->start]; |
@@ -65,7 +67,7 @@ void *rb_write(RingBuffer *b, void *p) | |||
65 | bool rb_read(RingBuffer *b, void **p) | 67 | bool rb_read(RingBuffer *b, void **p) |
66 | { | 68 | { |
67 | if (b->end == b->start) { /* Empty */ | 69 | if (b->end == b->start) { /* Empty */ |
68 | *p = NULL; | 70 | *p = nullptr; |
69 | return false; | 71 | return false; |
70 | } | 72 | } |
71 | 73 | ||
@@ -79,14 +81,14 @@ RingBuffer *rb_new(int size) | |||
79 | RingBuffer *buf = (RingBuffer *)calloc(sizeof(RingBuffer), 1); | 81 | RingBuffer *buf = (RingBuffer *)calloc(sizeof(RingBuffer), 1); |
80 | 82 | ||
81 | if (!buf) { | 83 | if (!buf) { |
82 | return NULL; | 84 | return nullptr; |
83 | } | 85 | } |
84 | 86 | ||
85 | buf->size = size + 1; /* include empty elem */ | 87 | buf->size = size + 1; /* include empty elem */ |
86 | 88 | ||
87 | if (!(buf->data = (void **)calloc(buf->size, sizeof(void *)))) { | 89 | if (!(buf->data = (void **)calloc(buf->size, sizeof(void *)))) { |
88 | free(buf); | 90 | free(buf); |
89 | return NULL; | 91 | return nullptr; |
90 | } | 92 | } |
91 | 93 | ||
92 | return buf; | 94 | return buf; |