XROAD
xroad_net_buf.h File Reference
#include "xroad_sock_fwd.h"
#include <common/xroad_common_types.h>
#include <logger/xroad_logger.h>
#include <stdint.h>
#include <stdlib.h>
Include dependency graph for xroad_net_buf.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  xroad_net_buf_s
 

Macros

#define xroad_net_buf_check(buf)
 

Functions

xroad_errno_t xroad_net_buf_create (xroad_net_buf_t *buf, size_t size, size_t max_size)
 
xroad_errno_t xroad_net_buf_resize (xroad_net_buf_t *buf, size_t size)
 
xroad_errno_t xroad_net_buf_increase (xroad_net_buf_t *buf, size_t size)
 
void xroad_net_buf_destroy (xroad_net_buf_t *buf)
 
void xroad_net_buf_free_space (xroad_net_buf_t *buf)
 

Detailed Description

Macro Definition Documentation

◆ xroad_net_buf_check

#define xroad_net_buf_check (   buf)
Value:
{ \
xroad_net_buf_t* buf777_ = (buf); \
assert(*(uint32_t*)buf777_->end == 0xDEADBEAF); \
assert(buf777_->data_begin >= buf777_->begin); \
assert(buf777_->data_begin <= buf777_->end); \
assert(buf777_->data_end >= buf777_->begin); \
assert(buf777_->data_end <= buf777_->end); \
assert(buf777_->data_begin <= buf777_->data_end); \
}

Function Documentation

◆ xroad_net_buf_create()

xroad_errno_t xroad_net_buf_create ( xroad_net_buf_t buf,
size_t  size,
size_t  max_size 
)

alocate new buffer

Parameters
[in]buf- buffer for witch data will be allocated
[in]size- initial size of data to allocate
[in]max_size- set maximum allocated data size
Returns
XROAD_OK - created, XROAD_FAILED - error

◆ xroad_net_buf_destroy()

void xroad_net_buf_destroy ( xroad_net_buf_t buf)

free buffer

Parameters
[in]buf- buffer to destroy

◆ xroad_net_buf_free_space()

void xroad_net_buf_free_space ( xroad_net_buf_t buf)

frees unused space in buffer

Parameters
[in]buf- buffer to free space

◆ xroad_net_buf_increase()

xroad_errno_t xroad_net_buf_increase ( xroad_net_buf_t buf,
size_t  size 
)

try to increase buffer size_t. If free space is greater than size, no increase performed

Parameters
[in]buf- buffer to increase
[in]size- increase space size
Returns
XROAD_ERROR_OK - increased, XROAD_ERROR_NO_MORE_SPACE - buffer space is a maximum

◆ xroad_net_buf_resize()

xroad_errno_t xroad_net_buf_resize ( xroad_net_buf_t buf,
size_t  size 
)

set buffer size

Parameters
[in]buf- buffer to manipulate
[in]size- new buffer size
Returns
XROAD_OK - changed XROAD_ERROR_NO_MORE_SPACE - buffer new size greater than max_size XROAD_ERROR_INVALID_ARGUMENT - wrong new buffer size