---
name: "libwget-bitmap"
section: "3"
platform: "linux"
package: "wget2-dev"
version: "2.2.0+ds-1+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/libwget-bitmap"
---

# libwget-bitmap(3)

Bitmap management functions

## NAME

libwget-bitmap - Bitmap management functions

## SYNOPSIS

### Data Structures

struct **wget\_bitmap\_st**\

### Macros

\#define **bitmap\_type**   uint64\_t\
 \#define **bitmap\_bits**   (sizeof(bitmap\_type) \* 8)\
 \#define **bitmap\_shift**   6\
 \#define **map**(n)   (((**wget\_bitmap** \*)b)-\>map\[(n) \>\> bitmap\_shift\])\
 \#define **bit**(n)   (((bitmap\_type) 1) \<\< ((n) & (bitmap\_bits - 1)))\

### Functions

void **wget\_bitmap\_set** (**wget\_bitmap** \*b, unsigned n)\
 void **wget\_bitmap\_clear** (**wget\_bitmap** \*b, unsigned n)\
 bool **wget\_bitmap\_get** (const **wget\_bitmap** \*b, unsigned n)\
 int **wget\_bitmap\_init** (**wget\_bitmap** \*\*b, unsigned bits)\
 void **wget\_bitmap\_free** (**wget\_bitmap** \*\*b)\

## Detailed Description

Bitmap (bit array) implementation.

This is useful when you need a bitmap with more than 64 bits. Up to 64 bits you can use the C99 uint64\_t as a standard C bitfield.

As a usage example, Wget2 uses bitmaps for options with lists of HTTP status codes, which have values of 100-699.

## Function Documentation

### void wget\_bitmap\_set (wget\_bitmap \* b, unsigned n)

**Parameters**

*b* Bitmap to act on \
 *n* Number of the bit to set (0-...)

Set the bit `n` in the bitmap `b`.

### void wget\_bitmap\_clear (wget\_bitmap \* b, unsigned n)

**Parameters**

*b* Bitmap to act on \
 *n* Number of the bit to clear (0-...)

Clear the bit `n` in the bitmap `b`.

### bool wget\_bitmap\_get (const wget\_bitmap \* b, unsigned n)

**Parameters**

*b* Bitmap to read from \
 *n* Number of the bit of interest (0-...)

**Returns**

0 if bit `n` is cleared or if `n` is out of range 1 if bit `is` set

Returns whether the bit `n` is set or not.

### int wget\_bitmap\_init (wget\_bitmap \*\* b, unsigned bits)

**Parameters**

*b* Pointer to the allocated bitmap \
 *bits* Number of bits

**Returns**

A **wget\_error** value

Allocates a bitmap with a capacity of `bits`. It must be freed by **wget\_bitmap\_free()** after usage.

### void wget\_bitmap\_free (wget\_bitmap \*\* b)

**Parameters**

*b* Pointer to bitmap to free

Frees and clears the bitmap pointed to by `b`.

## Author

Generated automatically by Doxygen for wget2 from the source code.
