Reindent server/core/buffer.c
This commit is contained in:
@ -56,8 +56,7 @@
|
||||
static HASHTABLE *buffer_hashtable = NULL;
|
||||
#endif
|
||||
|
||||
static buffer_object_t* gwbuf_remove_buffer_object(
|
||||
GWBUF* buf,
|
||||
static buffer_object_t* gwbuf_remove_buffer_object(GWBUF* buf,
|
||||
buffer_object_t* bufobj);
|
||||
|
||||
#if defined(BUFFER_TRACE)
|
||||
@ -87,7 +86,7 @@ SHARED_BUF *sbuf;
|
||||
/* Allocate the buffer header */
|
||||
if ((rval = (GWBUF *)malloc(sizeof(GWBUF))) == NULL)
|
||||
{
|
||||
goto retblock;;
|
||||
goto retblock;
|
||||
}
|
||||
|
||||
/* Allocate the shared data buffer */
|
||||
@ -241,7 +240,6 @@ void
|
||||
gwbuf_free(GWBUF *buf)
|
||||
{
|
||||
BUF_PROPERTY *prop;
|
||||
|
||||
buffer_object_t *bo;
|
||||
|
||||
CHK_GWBUF(buf);
|
||||
@ -325,8 +323,7 @@ GWBUF *rval;
|
||||
*
|
||||
* @return head of the cloned list or NULL if the list was empty.
|
||||
*/
|
||||
GWBUF* gwbuf_clone_all(
|
||||
GWBUF* buf)
|
||||
GWBUF* gwbuf_clone_all(GWBUF* buf)
|
||||
{
|
||||
GWBUF* rval;
|
||||
GWBUF* clonebuf;
|
||||
@ -349,8 +346,7 @@ GWBUF* gwbuf_clone_all(
|
||||
}
|
||||
|
||||
|
||||
GWBUF *gwbuf_clone_portion(
|
||||
GWBUF *buf,
|
||||
GWBUF *gwbuf_clone_portion(GWBUF *buf,
|
||||
size_t start_offset,
|
||||
size_t length)
|
||||
{
|
||||
@ -384,7 +380,6 @@ GWBUF *gwbuf_clone_portion(
|
||||
gwbuf_add_to_hashtable(clonebuf);
|
||||
#endif
|
||||
return clonebuf;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -393,9 +388,7 @@ GWBUF *gwbuf_clone_portion(
|
||||
* Return NULL if conversion between types is not supported or due lacking
|
||||
* type information.
|
||||
*/
|
||||
GWBUF *gwbuf_clone_transform(
|
||||
GWBUF * head,
|
||||
gwbuf_type_t targettype)
|
||||
GWBUF *gwbuf_clone_transform(GWBUF *head, gwbuf_type_t targettype)
|
||||
{
|
||||
gwbuf_type_t src_type;
|
||||
GWBUF* clonebuf;
|
||||
@ -417,8 +410,7 @@ GWBUF *gwbuf_clone_transform(
|
||||
if (GWBUF_TYPE_PLAINSQL == targettype)
|
||||
{
|
||||
/** Crete reference to string part of buffer */
|
||||
clonebuf = gwbuf_clone_portion(
|
||||
head,
|
||||
clonebuf = gwbuf_clone_portion(head,
|
||||
5,
|
||||
GWBUF_LENGTH(head) - 5);
|
||||
ss_dassert(clonebuf != NULL);
|
||||
@ -454,9 +446,13 @@ GWBUF *
|
||||
gwbuf_append(GWBUF *head, GWBUF *tail)
|
||||
{
|
||||
if (!head)
|
||||
{
|
||||
return tail;
|
||||
}
|
||||
if (!tail)
|
||||
{
|
||||
return head;
|
||||
}
|
||||
CHK_GWBUF(head);
|
||||
head->tail->next = tail;
|
||||
head->tail = tail->tail;
|
||||
@ -493,7 +489,9 @@ GWBUF *rval = head;
|
||||
{
|
||||
rval = head->next;
|
||||
if (head->next)
|
||||
{
|
||||
head->next->tail = head->tail;
|
||||
}
|
||||
|
||||
gwbuf_free(head);
|
||||
}
|
||||
@ -603,8 +601,7 @@ void gwbuf_set_type(
|
||||
* @param data Object data
|
||||
* @param donefun_dp Clean-up function to be executed before buffer is freed.
|
||||
*/
|
||||
void gwbuf_add_buffer_object(
|
||||
GWBUF* buf,
|
||||
void gwbuf_add_buffer_object(GWBUF* buf,
|
||||
bufobj_id_t id,
|
||||
void* data,
|
||||
void (*donefun_fp)(void *))
|
||||
@ -650,9 +647,7 @@ void gwbuf_add_buffer_object(
|
||||
*
|
||||
* @return Searched buffer object or NULL if not found
|
||||
*/
|
||||
void* gwbuf_get_buffer_object_data(
|
||||
GWBUF* buf,
|
||||
bufobj_id_t id)
|
||||
void* gwbuf_get_buffer_object_data(GWBUF* buf, bufobj_id_t id)
|
||||
{
|
||||
buffer_object_t* bo;
|
||||
|
||||
@ -676,9 +671,7 @@ void* gwbuf_get_buffer_object_data(
|
||||
/**
|
||||
* @return pointer to next buffer object or NULL
|
||||
*/
|
||||
static buffer_object_t* gwbuf_remove_buffer_object(
|
||||
GWBUF* buf,
|
||||
buffer_object_t* bufobj)
|
||||
static buffer_object_t* gwbuf_remove_buffer_object(GWBUF* buf, buffer_object_t* bufobj)
|
||||
{
|
||||
buffer_object_t* next;
|
||||
|
||||
@ -689,8 +682,6 @@ static buffer_object_t* gwbuf_remove_buffer_object(
|
||||
return next;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add a property to a buffer.
|
||||
*
|
||||
@ -735,10 +726,14 @@ BUF_PROPERTY *prop;
|
||||
spinlock_acquire(&buf->gwbuf_lock);
|
||||
prop = buf->properties;
|
||||
while (prop && strcmp(prop->name, name) != 0)
|
||||
{
|
||||
prop = prop->next;
|
||||
}
|
||||
spinlock_release(&buf->gwbuf_lock);
|
||||
if (prop)
|
||||
{
|
||||
return prop->value;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -757,9 +752,13 @@ char *ptr;
|
||||
int len;
|
||||
|
||||
if (orig == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
if (orig->next == NULL)
|
||||
{
|
||||
return orig;
|
||||
}
|
||||
|
||||
if ((newbuf = gwbuf_alloc(gwbuf_length(orig))) != NULL)
|
||||
{
|
||||
@ -795,7 +794,9 @@ HINT *ptr;
|
||||
{
|
||||
ptr = buf->hint;
|
||||
while (ptr->next)
|
||||
{
|
||||
ptr = ptr->next;
|
||||
}
|
||||
ptr->next = hint;
|
||||
}
|
||||
else
|
||||
|
@ -60,7 +60,8 @@ EXTERN_C_BLOCK_BEGIN
|
||||
* contents. This may be added at any point during the processing of the
|
||||
* data, especially in the protocol stage of the processing.
|
||||
*/
|
||||
typedef struct buf_property {
|
||||
typedef struct buf_property
|
||||
{
|
||||
char *name;
|
||||
char *value;
|
||||
struct buf_property *next;
|
||||
@ -91,7 +92,8 @@ typedef enum
|
||||
* shared between multiple GWBUF's without the need to make multiple copies
|
||||
* but still maintain separate data pointers.
|
||||
*/
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
unsigned char *data; /*< Physical memory that was allocated */
|
||||
int refcount; /*< Reference count on the buffer */
|
||||
} SHARED_BUF;
|
||||
@ -117,7 +119,8 @@ typedef enum
|
||||
|
||||
typedef struct buffer_object_st buffer_object_t;
|
||||
|
||||
struct buffer_object_st {
|
||||
struct buffer_object_st
|
||||
{
|
||||
bufobj_id_t bo_id;
|
||||
void* bo_data;
|
||||
void (*bo_donefun_fp)(void *);
|
||||
@ -133,7 +136,8 @@ struct buffer_object_st {
|
||||
* flexible data pointers is designed to minimise the need for data to
|
||||
* be copied within the gateway.
|
||||
*/
|
||||
typedef struct gwbuf {
|
||||
typedef struct gwbuf
|
||||
{
|
||||
SPINLOCK gwbuf_lock;
|
||||
struct gwbuf *next; /*< Next buffer in a linked chain of buffers */
|
||||
struct gwbuf *tail; /*< Last buffer in a linked chain of buffers */
|
||||
@ -169,12 +173,15 @@ typedef struct gwbuf {
|
||||
#define GWBUF_CONSUME(b, bytes) ((b)->start = bytes > ((char *)(b)->end - (char *)(b)->start) ? (b)->end : (void *)((char *)(b)->start + (bytes)));
|
||||
|
||||
/*< Check if a given pointer is within the buffer */
|
||||
#define GWBUF_POINTER_IN_BUFFER (ptr, b) ((char *)(ptr) >= (char *)(b)->start && (char *)(ptr) < (char *)(b)->end)
|
||||
#define GWBUF_POINTER_IN_BUFFER (ptr, b)\
|
||||
((char *)(ptr) >= (char *)(b)->start && (char *)(ptr) < (char *)(b)->end)
|
||||
|
||||
/*< Consume a complete buffer */
|
||||
#define GWBUF_CONSUME_ALL(b) gwbuf_consume((b), GWBUF_LENGTH((b)))
|
||||
|
||||
#define GWBUF_RTRIM(b, bytes) ((b)->end = bytes > ((char *)(b)->end - (char *)(b)->start) ? (b)->start : (void *)((char *)(b)->end - (bytes)));
|
||||
#define GWBUF_RTRIM(b, bytes)\
|
||||
((b)->end = bytes > ((char *)(b)->end - (char *)(b)->start) ? (b)->start : \
|
||||
(void *)((char *)(b)->end - (bytes)));
|
||||
|
||||
#define GWBUF_TYPE(b) (b)->gwbuf_type
|
||||
/*<
|
||||
|
Reference in New Issue
Block a user