tor  0.4.0.1-alpha
Macros | Typedefs | Functions
bitarray.h File Reference
#include "orconfig.h"
#include <string.h>
#include "lib/cc/torint.h"
#include "lib/malloc/malloc.h"

Go to the source code of this file.

Macros

#define BITARRAY_MASK   ((1u<<BITARRAY_SHIFT)-1)
 
#define bitarray_free(ba)   FREE_AND_NULL(bitarray_t, bitarray_free_, (ba))
 

Typedefs

typedef unsigned int bitarray_t
 

Functions

static bitarray_tbitarray_init_zero (unsigned int n_bits)
 
static bitarray_tbitarray_expand (bitarray_t *ba, unsigned int n_bits_old, unsigned int n_bits_new)
 
static void bitarray_free_ (bitarray_t *ba)
 
static void bitarray_set (bitarray_t *b, int bit)
 
static void bitarray_clear (bitarray_t *b, int bit)
 
static unsigned int bitarray_is_set (bitarray_t *b, int bit)
 

Detailed Description

Implements a variable-sized (but non-resizeable) bit-array.

Definition in file bitarray.h.

Typedef Documentation

◆ bitarray_t

typedef unsigned int bitarray_t

A random-access array of one-bit-wide elements.

Definition at line 30 of file bitarray.h.

Function Documentation

◆ bitarray_clear()

static void bitarray_clear ( bitarray_t b,
int  bit 
)
inlinestatic

Set the bitth bit in b to 0.

Definition at line 74 of file bitarray.h.

◆ bitarray_expand()

static bitarray_t* bitarray_expand ( bitarray_t ba,
unsigned int  n_bits_old,
unsigned int  n_bits_new 
)
inlinestatic

Expand ba from holding n_bits_old to n_bits_new, clearing all new bits. Returns a possibly changed pointer to the bitarray.

Definition at line 43 of file bitarray.h.

◆ bitarray_free_()

static void bitarray_free_ ( bitarray_t ba)
inlinestatic

Free the bit array ba.

Definition at line 60 of file bitarray.h.

References tor_free.

◆ bitarray_init_zero()

static bitarray_t* bitarray_init_zero ( unsigned int  n_bits)
inlinestatic

Create a new bit array that can hold n_bits bits.

Definition at line 33 of file bitarray.h.

Referenced by rep_hist_remove_predicted_ports().

◆ bitarray_is_set()

static unsigned int bitarray_is_set ( bitarray_t b,
int  bit 
)
inlinestatic

Return true iff bitth bit in b is nonzero. NOTE: does not necessarily return 1 on true.

Definition at line 81 of file bitarray.h.

Referenced by bloomfilt_probably_contains(), rep_hist_remove_predicted_ports(), and routerset_contains().

◆ bitarray_set()

static void bitarray_set ( bitarray_t b,
int  bit 
)
inlinestatic

Set the bitth bit in b to 1.

Definition at line 68 of file bitarray.h.

Referenced by bloomfilt_add(), and rep_hist_remove_predicted_ports().