diff --git a/packet-radio/src/packet_buffer.c b/packet-radio/src/packet_buffer.c index 1b66466..64cda9f 100644 --- a/packet-radio/src/packet_buffer.c +++ b/packet-radio/src/packet_buffer.c @@ -1,3 +1,14 @@ +/* +Copyright 2022, Savanni D'Gerinel + +This file is part of Savanni's AVR library. + +This AVR library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + +This AVR library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this AVR library. If not, see . +*/ #include "radio.h" #include "packet.h" @@ -7,7 +18,15 @@ size_t circular_next(size_t current, size_t max); packet_buffer_t *packet_buffer_new() { - return malloc(sizeof(packet_buffer_t)); + packet_buffer_t *buffer = malloc(sizeof(packet_buffer_t)); + packet_buffer_init(buffer); + return buffer; +} + +void packet_buffer_init(packet_buffer_t *buffer) { + buffer->count = 0; + buffer->bottom = 0; + buffer->top = 0; } packet_t *packet_buffer_enqueue(packet_buffer_t *self, packet_buffer_status_e *status) { diff --git a/packet-radio/src/packet_buffer.h b/packet-radio/src/packet_buffer.h index c7320de..4f8542e 100644 --- a/packet-radio/src/packet_buffer.h +++ b/packet-radio/src/packet_buffer.h @@ -1,9 +1,19 @@ +/* +Copyright 2022, Savanni D'Gerinel + +This file is part of Savanni's AVR library. + +This AVR library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + +This AVR library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this AVR library. If not, see . +*/ #ifndef __PACKET_BUFFER_H__ #define __PACKET_BUFFER_H__ #include "packet.h" -#include typedef enum { packet_buffer_status_ok, @@ -19,6 +29,7 @@ typedef struct { } packet_buffer_t; packet_buffer_t *packet_buffer_new(); +void packet_buffer_init(packet_buffer_t *); packet_t * packet_buffer_enqueue(packet_buffer_t *, packet_buffer_status_e *); packet_t * packet_buffer_head(packet_buffer_t *, packet_buffer_status_e *);