forked from Imagelibrary/rtems
capture: Fix buffer allocation and free
Do not use function static variables. Remove superfluous volatile qualifiers. Use proper integer types. Close #2706.
This commit is contained in:
@@ -28,8 +28,8 @@
|
|||||||
|
|
||||||
void * rtems_capture_buffer_allocate( rtems_capture_buffer_t* buffer, size_t size )
|
void * rtems_capture_buffer_allocate( rtems_capture_buffer_t* buffer, size_t size )
|
||||||
{
|
{
|
||||||
static uint32_t end;
|
size_t end;
|
||||||
static void *ptr;
|
void *ptr;
|
||||||
|
|
||||||
if ( rtems_capture_buffer_is_full( buffer ) )
|
if ( rtems_capture_buffer_is_full( buffer ) )
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -89,9 +89,9 @@ void * rtems_capture_buffer_allocate( rtems_capture_buffer_t* buffer, size_t siz
|
|||||||
|
|
||||||
void *rtems_capture_buffer_free( rtems_capture_buffer_t* buffer, size_t size )
|
void *rtems_capture_buffer_free( rtems_capture_buffer_t* buffer, size_t size )
|
||||||
{
|
{
|
||||||
static void *ptr;
|
void *ptr;
|
||||||
static uint32_t next;
|
size_t next;
|
||||||
size_t buff_size;
|
size_t buff_size;
|
||||||
|
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@@ -32,12 +32,12 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t *buffer;
|
uint8_t *buffer;
|
||||||
size_t size;
|
size_t size;
|
||||||
volatile uint32_t count;
|
size_t count;
|
||||||
volatile uint32_t head;
|
size_t head;
|
||||||
volatile uint32_t tail;
|
size_t tail;
|
||||||
volatile uint32_t end;
|
size_t end;
|
||||||
} rtems_capture_buffer_t;
|
} rtems_capture_buffer_t;
|
||||||
|
|
||||||
static inline void rtems_capture_buffer_flush( rtems_capture_buffer_t* buffer )
|
static inline void rtems_capture_buffer_flush( rtems_capture_buffer_t* buffer )
|
||||||
|
|||||||
Reference in New Issue
Block a user