NetSurf
Macros
ring.h File Reference

Ring list structure. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define RING_INSERT(ring, element)
 Insert the given item into the specified ring. More...
 
#define RING_REMOVE(ring, element)
 Remove the given element from the specified ring. More...
 
#define RING_FINDBYLWCHOST(ring, element, lwc_hostname)
 Find the element (by hostname) in the given ring, leave it in the provided element variable. More...
 
#define RING_GETSIZE(ringtype, ring, sizevar)
 Measure the size of a ring and put it in the supplied variable. More...
 
#define RING_COUNTBYLWCHOST(ringtype, ring, sizevar, lwc_hostname)
 Count the number of elements in the ring which match the provided lwc_hostname. More...
 
#define RING_ITERATE_START(ringtype, ring, iteratorptr)
 
#define RING_ITERATE_STOP(ring, iteratorptr)    goto iteration_end_ring##_##iteratorptr
 
#define RING_ITERATE_END(ring, iteratorptr)
 

Detailed Description

Ring list structure.

Rings are structures which have an r_next pointer and an r_prev pointer which are always initialised and always point at the next or previous element respectively.

The degenerate case of a single element in the ring simply points at itself in both directions. A zero element ring is NULL.

Some of the ring functions are specific to the fetcher but may be of use to others and are thus included here.

Definition in file ring.h.

Macro Definition Documentation

◆ RING_COUNTBYLWCHOST

#define RING_COUNTBYLWCHOST (   ringtype,
  ring,
  sizevar,
  lwc_hostname 
)
Value:
/*LOG("RING_COUNTBYHOST(%s, %s)", #ring, hostname);*/ \
if (ring) { \
ringtype *p = ring; \
sizevar = 0; \
do { \
bool matches = false; \
/* nsurl guarantees lowercase host */ \
if (lwc_string_isequal(p->host, lwc_hostname, \
&matches) == lwc_error_ok) \
if (matches) \
sizevar++; \
p = p->r_next; \
} while (p != ring); \
} else sizevar = 0
static struct fetch_rsrc_context * ring
Definition: fetch_rsrc.cpp:68
struct fetch_rsrc_context * r_next
Definition: fetch_rsrc.cpp:65

Count the number of elements in the ring which match the provided lwc_hostname.

Definition at line 98 of file ring.h.

◆ RING_FINDBYLWCHOST

#define RING_FINDBYLWCHOST (   ring,
  element,
  lwc_hostname 
)
Value:
/*LOG("RING_FINDBYHOST(%s, %s)", #ring, hostname);*/ \
if (ring) { \
bool found = false; \
element = ring; \
do { \
if (lwc_string_isequal(element->host, lwc_hostname, \
&found) == lwc_error_ok && \
found == true) { \
break; \
} \
element = element->r_next; \
} while (element != ring); \
if (!found) element = 0; \
} else element = 0

Find the element (by hostname) in the given ring, leave it in the provided element variable.

Definition at line 69 of file ring.h.

◆ RING_GETSIZE

#define RING_GETSIZE (   ringtype,
  ring,
  sizevar 
)
Value:
/*LOG("RING_GETSIZE(%s)", #ring);*/ \
if (ring) { \
ringtype *p = ring; \
sizevar = 0; \
do { \
sizevar++; \
p = p->r_next; \
} while (p != ring); \
} else sizevar = 0

Measure the size of a ring and put it in the supplied variable.

Definition at line 86 of file ring.h.

◆ RING_INSERT

#define RING_INSERT (   ring,
  element 
)
Value:
/*LOG("RING_INSERT(%s, %p(%s))", #ring, element, element->host);*/ \
if (ring) { \
element->r_next = ring; \
element->r_prev = ring->r_prev; \
ring->r_prev = element; \
element->r_prev->r_next = element; \
} else \
ring = element->r_prev = element->r_next = element
struct fetch_rsrc_context * r_prev
Definition: fetch_rsrc.cpp:65

Insert the given item into the specified ring.

Assumes that the element is zeroed as appropriate.

Definition at line 40 of file ring.h.

◆ RING_ITERATE_END

#define RING_ITERATE_END (   ring,
  iteratorptr 
)
Value:
} while (false); \
iteratorptr = iteratorptr->r_next; \
} while (iteratorptr != ring); \
} \
iteration_end_ring##_##iteratorptr:

Definition at line 136 of file ring.h.

◆ RING_ITERATE_START

#define RING_ITERATE_START (   ringtype,
  ring,
  iteratorptr 
)
Value:
if (ring != NULL) { \
ringtype *iteratorptr = ring; \
do { \
do { \

Definition at line 127 of file ring.h.

◆ RING_ITERATE_STOP

#define RING_ITERATE_STOP (   ring,
  iteratorptr 
)     goto iteration_end_ring##_##iteratorptr

Definition at line 133 of file ring.h.

◆ RING_REMOVE

#define RING_REMOVE (   ring,
  element 
)
Value:
/*LOG("RING_REMOVE(%s, %p(%s)", #ring, element, element->host);*/ \
if (element->r_next != element ) { \
/* Not the only thing in the ring */ \
element->r_next->r_prev = element->r_prev; \
element->r_prev->r_next = element->r_next; \
if (ring == element) ring = element->r_next; \
} else { \
/* Only thing in the ring */ \
ring = 0; \
} \
element->r_next = element->r_prev = 0

Remove the given element from the specified ring.

Will zero the element as needed

Definition at line 53 of file ring.h.