Skip to content

Commit

Permalink
Re-format files according to clang-format style rules.
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipjohnston committed Oct 12, 2021
1 parent 5b07c59 commit 434d334
Show file tree
Hide file tree
Showing 87 changed files with 10,894 additions and 8,067 deletions.
68 changes: 34 additions & 34 deletions examples/c/circular_buffer/circular_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
#include "circular_buffer.h"

// The definition of our circular buffer structure is hidden from the user
struct circular_buf_t {
uint8_t * buffer;
struct circular_buf_t
{
uint8_t* buffer;
size_t head;
size_t tail;
size_t max; //of the buffer
size_t max; // of the buffer
bool full;
};

Expand All @@ -21,9 +22,9 @@ static void advance_pointer(cbuf_handle_t cbuf)
assert(cbuf);

if(circular_buf_full(cbuf))
{
cbuf->tail = (cbuf->tail + 1) % cbuf->max;
}
{
cbuf->tail = (cbuf->tail + 1) % cbuf->max;
}

cbuf->head = (cbuf->head + 1) % cbuf->max;

Expand Down Expand Up @@ -65,11 +66,11 @@ void circular_buf_free(cbuf_handle_t cbuf)

void circular_buf_reset(cbuf_handle_t cbuf)
{
assert(cbuf);
assert(cbuf);

cbuf->head = 0;
cbuf->tail = 0;
cbuf->full = false;
cbuf->head = 0;
cbuf->tail = 0;
cbuf->full = false;
}

size_t circular_buf_size(cbuf_handle_t cbuf)
Expand All @@ -88,7 +89,6 @@ size_t circular_buf_size(cbuf_handle_t cbuf)
{
size = (cbuf->max + cbuf->head - cbuf->tail);
}

}

return size;
Expand All @@ -105,54 +105,54 @@ void circular_buf_put(cbuf_handle_t cbuf, uint8_t data)
{
assert(cbuf && cbuf->buffer);

cbuf->buffer[cbuf->head] = data;
cbuf->buffer[cbuf->head] = data;

advance_pointer(cbuf);
advance_pointer(cbuf);
}

int circular_buf_put2(cbuf_handle_t cbuf, uint8_t data)
{
int r = -1;
int r = -1;

assert(cbuf && cbuf->buffer);
assert(cbuf && cbuf->buffer);

if(!circular_buf_full(cbuf))
{
cbuf->buffer[cbuf->head] = data;
advance_pointer(cbuf);
r = 0;
}
if(!circular_buf_full(cbuf))
{
cbuf->buffer[cbuf->head] = data;
advance_pointer(cbuf);
r = 0;
}

return r;
return r;
}

int circular_buf_get(cbuf_handle_t cbuf, uint8_t * data)
int circular_buf_get(cbuf_handle_t cbuf, uint8_t* data)
{
assert(cbuf && data && cbuf->buffer);
assert(cbuf && data && cbuf->buffer);

int r = -1;
int r = -1;

if(!circular_buf_empty(cbuf))
{
*data = cbuf->buffer[cbuf->tail];
retreat_pointer(cbuf);
if(!circular_buf_empty(cbuf))
{
*data = cbuf->buffer[cbuf->tail];
retreat_pointer(cbuf);

r = 0;
}
r = 0;
}

return r;
return r;
}

bool circular_buf_empty(cbuf_handle_t cbuf)
{
assert(cbuf);

return (!circular_buf_full(cbuf) && (cbuf->head == cbuf->tail));
return (!circular_buf_full(cbuf) && (cbuf->head == cbuf->tail));
}

bool circular_buf_full(cbuf_handle_t cbuf)
{
assert(cbuf);

return cbuf->full;
return cbuf->full;
}
8 changes: 4 additions & 4 deletions examples/c/circular_buffer/circular_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int circular_buf_put2(cbuf_handle_t cbuf, uint8_t data);
/// Retrieve a value from the buffer
/// Requires: cbuf is valid and created by circular_buf_init
/// Returns 0 on success, -1 if the buffer is empty
int circular_buf_get(cbuf_handle_t cbuf, uint8_t * data);
int circular_buf_get(cbuf_handle_t cbuf, uint8_t* data);

/// CHecks if the buffer is empty
/// Requires: cbuf is valid and created by circular_buf_init
Expand All @@ -59,7 +59,7 @@ size_t circular_buf_capacity(cbuf_handle_t cbuf);
/// Returns the current number of elements in the buffer
size_t circular_buf_size(cbuf_handle_t cbuf);

//TODO: int circular_buf_get_range(circular_buf_t cbuf, uint8_t *data, size_t len);
//TODO: int circular_buf_put_range(circular_buf_t cbuf, uint8_t * data, size_t len);
// TODO: int circular_buf_get_range(circular_buf_t cbuf, uint8_t *data, size_t len);
// TODO: int circular_buf_put_range(circular_buf_t cbuf, uint8_t * data, size_t len);

#endif //CIRCULAR_BUFFER_H_
#endif // CIRCULAR_BUFFER_H_
78 changes: 39 additions & 39 deletions examples/c/circular_buffer/circular_buffer_no_modulo.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
#include "circular_buffer.h"

// The definition of our circular buffer structure is hidden from the user
struct circular_buf_t {
uint8_t * buffer;
struct circular_buf_t
{
uint8_t* buffer;
size_t head;
size_t tail;
size_t max; //of the buffer
size_t max; // of the buffer
bool full;
};

Expand All @@ -21,14 +22,14 @@ static void advance_pointer(cbuf_handle_t cbuf)
assert(cbuf);

if(circular_buf_full(cbuf))
{
if(++(cbuf->tail) == cbuf->max)
{
cbuf->tail = 0;
}
}

if(++(cbuf->head) == cbuf->max)
{
if(++(cbuf->tail) == cbuf->max)
{
cbuf->tail = 0;
}
}

if(++(cbuf->head) == cbuf->max)
{
cbuf->head = 0;
}
Expand Down Expand Up @@ -74,11 +75,11 @@ void circular_buf_free(cbuf_handle_t cbuf)

void circular_buf_reset(cbuf_handle_t cbuf)
{
assert(cbuf);
assert(cbuf);

cbuf->head = 0;
cbuf->tail = 0;
cbuf->full = false;
cbuf->head = 0;
cbuf->tail = 0;
cbuf->full = false;
}

size_t circular_buf_size(cbuf_handle_t cbuf)
Expand All @@ -97,7 +98,6 @@ size_t circular_buf_size(cbuf_handle_t cbuf)
{
size = (cbuf->max + cbuf->head - cbuf->tail);
}

}

return size;
Expand All @@ -114,54 +114,54 @@ void circular_buf_put(cbuf_handle_t cbuf, uint8_t data)
{
assert(cbuf && cbuf->buffer);

cbuf->buffer[cbuf->head] = data;
cbuf->buffer[cbuf->head] = data;

advance_pointer(cbuf);
advance_pointer(cbuf);
}

int circular_buf_put2(cbuf_handle_t cbuf, uint8_t data)
{
int r = -1;
int r = -1;

assert(cbuf && cbuf->buffer);
assert(cbuf && cbuf->buffer);

if(!circular_buf_full(cbuf))
{
cbuf->buffer[cbuf->head] = data;
advance_pointer(cbuf);
r = 0;
}
if(!circular_buf_full(cbuf))
{
cbuf->buffer[cbuf->head] = data;
advance_pointer(cbuf);
r = 0;
}

return r;
return r;
}

int circular_buf_get(cbuf_handle_t cbuf, uint8_t * data)
int circular_buf_get(cbuf_handle_t cbuf, uint8_t* data)
{
assert(cbuf && data && cbuf->buffer);
assert(cbuf && data && cbuf->buffer);

int r = -1;
int r = -1;

if(!circular_buf_empty(cbuf))
{
*data = cbuf->buffer[cbuf->tail];
retreat_pointer(cbuf);
if(!circular_buf_empty(cbuf))
{
*data = cbuf->buffer[cbuf->tail];
retreat_pointer(cbuf);

r = 0;
}
r = 0;
}

return r;
return r;
}

bool circular_buf_empty(cbuf_handle_t cbuf)
{
assert(cbuf);

return (!circular_buf_full(cbuf) && (cbuf->head == cbuf->tail));
return (!circular_buf_full(cbuf) && (cbuf->head == cbuf->tail));
}

bool circular_buf_full(cbuf_handle_t cbuf)
{
assert(cbuf);

return cbuf->full;
return cbuf->full;
}
Loading

0 comments on commit 434d334

Please sign in to comment.