Utility functions that did not fit into other modules.  
More...
 | 
| #define  | containerof(ptr,  type,  member)   ((type *) (((char *) ptr) - offsetof(type, member))) | 
|   | 
| #define  | lengthof(x)   ((sizeof(x) / sizeof(*(x)))) | 
|   | 
| #define  | verify(x)   assert(x) | 
|   | 
| #define  | RATELIMIT_TO(n,  window,  fn)                                                                                     | 
|   | Ratelimit a single expression.  More...
  | 
|   | 
| #define  | RATELIMIT(fn)   RATELIMIT_TO(3, 10, fn) | 
|   | Ratelimit a single expression using default ratelimiter values.  More...
  | 
|   | 
Utility functions that did not fit into other modules. 
      
        
          | #define containerof | 
          ( | 
            | 
          ptr,  | 
        
        
           | 
           | 
            | 
          type,  | 
        
        
           | 
           | 
            | 
          member  | 
        
        
           | 
          ) | 
           |    ((type *) (((char *) ptr) - offsetof(type, member))) | 
        
      
 
This macro is similar to the Linux kernel's container_of() macro but doesn't use the GNU extension needed to assure type safety. 
Definition at line 35 of file util.h.
 
 
      
        
          | #define lengthof | 
          ( | 
            | 
          x | ) | 
             ((sizeof(x) / sizeof(*(x)))) | 
        
      
 
Determine the number of elements in a statically allocated array.
There's no compile-time checks to this macro. Abuse it and you'll just get the wrong result! 
Definition at line 44 of file util.h.
 
 
Ratelimit a single expression using default ratelimiter values. 
Definition at line 106 of file util.h.
 
 
      
        
          | #define RATELIMIT_TO | 
          ( | 
            | 
          n,  | 
        
        
           | 
           | 
            | 
          window,  | 
        
        
           | 
           | 
            | 
          fn  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Value:{                                                                      \
                        (fn);                                                  \
        }
bool ratelimit_check(ratelimit_state_t *rs, uint32_t n, uint32_t window)
Check that the rate limiter has not triggered. 
 
Control structure used for rate limiting. 
 
 
Ratelimit a single expression. 
The expression will automatically be provides a private ratelimit_state_t; 
Definition at line 96 of file util.h.
 
 
      
        
          | #define verify | 
          ( | 
            | 
          x | ) | 
             assert(x) | 
        
      
 
 
      
        
          | int32_t cyclecmp32  | 
          ( | 
          uint32_t  | 
          a,  | 
        
        
           | 
           | 
          uint32_t  | 
          b  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Compares values that may be subject to overflow. 
This comparision assumes that 0 > 0xffffffff because, in 32-bit unsigned maths, 0 == 0xffffffff + 1. This is particular useful for working with 32-bit representations of time.
- Returns
 - >0 if a > b 
 
- 
0 if a == b 
 
- 
<0 if a < b 
 
Definition at line 19 of file util.c.
 
 
Check that the rate limiter has not triggered. 
The rate limiter will trigger if there are more than n events each window.
- Returns
 - true, if the ratelimited activity should be performed; false otherwise. 
 
Definition at line 24 of file util.c.
 
 
      
        
          | void rf_internal_out_of_memory  | 
          ( | 
          void  | 
           | ) | 
           | 
        
      
 
Out of memory hook.
- Todo:
 - Currently out_of_memory cannot actually be hooked 
 
Definition at line 40 of file util.c.
 
 
      
        
          | void* xmalloc  | 
          ( | 
          size_t  | 
          sz | ) | 
           |