Changed all arithmetic operations on raw void pointers to properly use uint8_t pointers instead.
This commit is contained in:
Markus Makela
2014-09-29 13:07:30 +03:00
parent fa47bf760a
commit ea6a3f56d6
2 changed files with 5 additions and 4 deletions

View File

@ -87,7 +87,7 @@ SHARED_BUF *sbuf;
} }
spinlock_init(&rval->gwbuf_lock); spinlock_init(&rval->gwbuf_lock);
rval->start = sbuf->data; rval->start = sbuf->data;
rval->end = rval->start + size; rval->end = (void*)((uint8_t*)rval->start + size);
sbuf->refcount = 1; sbuf->refcount = 1;
rval->sbuf = sbuf; rval->sbuf = sbuf;
rval->next = NULL; rval->next = NULL;

View File

@ -47,6 +47,7 @@
#include <skygw_debug.h> #include <skygw_debug.h>
#include <hint.h> #include <hint.h>
#include <spinlock.h> #include <spinlock.h>
#include <stdint.h>
EXTERN_C_BLOCK_BEGIN EXTERN_C_BLOCK_BEGIN
@ -150,15 +151,15 @@ typedef struct gwbuf {
#define GWBUF_DATA(b) ((b)->start) #define GWBUF_DATA(b) ((b)->start)
/*< Number of bytes in the individual buffer */ /*< Number of bytes in the individual buffer */
#define GWBUF_LENGTH(b) ((b)->end - (b)->start) #define GWBUF_LENGTH(b) ((unsigned int)(((uint8_t*)(b)->end) - ((uint8_t*)(b)->start)))
/*< True if all bytes in the buffer have been consumed */ /*< True if all bytes in the buffer have been consumed */
#define GWBUF_EMPTY(b) ((b)->start == (b)->end) #define GWBUF_EMPTY(b) ((b)->start == (b)->end)
/*< Consume a number of bytes in the buffer */ /*< Consume a number of bytes in the buffer */
#define GWBUF_CONSUME(b, bytes) (b)->start += (bytes) #define GWBUF_CONSUME(b, bytes) (b)->start = (void*)((uint8_t*)(b)->start + (bytes))
#define GWBUF_RTRIM(b, bytes) (b)->end -= (bytes) #define GWBUF_RTRIM(b, bytes) (b)->end = (void*)((uint8_t*)(b)->end - (bytes))
#define GWBUF_TYPE(b) (b)->gwbuf_type #define GWBUF_TYPE(b) (b)->gwbuf_type
/*< /*<