OpenVPN
Macros
circ_list.h File Reference
#include "basic.h"
#include "integer.h"
#include "error.h"
Include dependency graph for circ_list.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CIRC_LIST(name, type)
 
#define CIRC_LIST_PUSH(obj, item)
 
#define CIRC_LIST_SIZE(obj)   ((obj)->x_size)
 
#define CIRC_LIST_INDEX(obj, index)
 
#define CIRC_LIST_ITEM(obj, index)   ((obj)->x_list[CIRC_LIST_INDEX((obj), (index))])
 
#define CIRC_LIST_RESET(obj)
 
#define CIRC_LIST_ALLOC(dest, list_type, size)
 
#define CIRC_LIST_FREE(dest)   free(dest)
 

Macro Definition Documentation

◆ CIRC_LIST

#define CIRC_LIST (   name,
  type 
)
Value:
struct name { \
int x_head; \
int x_size; \
int x_cap; \
int x_sizeof; \
type x_list[EMPTY_ARRAY_SIZE]; \
}
#define EMPTY_ARRAY_SIZE
Definition: config-msvc.h:87

Definition at line 31 of file circ_list.h.

◆ CIRC_LIST_ALLOC

#define CIRC_LIST_ALLOC (   dest,
  list_type,
  size 
)
Value:
{ \
const int so = sizeof(list_type) + sizeof((dest)->x_list[0]) * (size); \
(dest) = (list_type *) malloc(so); \
check_malloc_return(dest); \
memset((dest), 0, so); \
(dest)->x_cap = size; \
(dest)->x_sizeof = so; \
}
#define malloc
Definition: cmocka.c:1795
char * dest
Definition: compat-lz4.h:431

Definition at line 64 of file circ_list.h.

Referenced by packet_id_init().

◆ CIRC_LIST_FREE

#define CIRC_LIST_FREE (   dest)    free(dest)

Definition at line 74 of file circ_list.h.

◆ CIRC_LIST_INDEX

#define CIRC_LIST_INDEX (   obj,
  index 
)
Value:
modulo_add((obj)->x_head, \
index_verify((index), (obj)->x_size, __FILE__, __LINE__), \
(obj)->x_cap)
static int modulo_add(int x, int y, int mod)
Definition: integer.h:116
static int index_verify(int index, int size, const char *file, int line)
Definition: integer.h:150

Definition at line 50 of file circ_list.h.

◆ CIRC_LIST_ITEM

#define CIRC_LIST_ITEM (   obj,
  index 
)    ((obj)->x_list[CIRC_LIST_INDEX((obj), (index))])

Definition at line 55 of file circ_list.h.

Referenced by packet_id_add(), packet_id_persist_print(), packet_id_reap(), and packet_id_test().

◆ CIRC_LIST_PUSH

#define CIRC_LIST_PUSH (   obj,
  item 
)
Value:
{ \
(obj)->x_head = modulo_add((obj)->x_head, -1, (obj)->x_cap); \
(obj)->x_list[(obj)->x_head] = (item); \
(obj)->x_size = min_int((obj)->x_size + 1, (obj)->x_cap); \
}
static int modulo_add(int x, int y, int mod)
Definition: integer.h:116
static int min_int(int x, int y)
Definition: integer.h:57

Definition at line 40 of file circ_list.h.

Referenced by packet_id_add().

◆ CIRC_LIST_RESET

#define CIRC_LIST_RESET (   obj)
Value:
{ \
(obj)->x_head = 0; \
(obj)->x_size = 0; \
}

Definition at line 58 of file circ_list.h.

Referenced by packet_id_add().

◆ CIRC_LIST_SIZE

#define CIRC_LIST_SIZE (   obj)    ((obj)->x_size)

Definition at line 47 of file circ_list.h.

Referenced by packet_id_add(), packet_id_reap(), and packet_id_test().