---
name: "q_init"
section: "3"
platform: "linux"
package: "liblibrecast-dev"
version: "0.9.1-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/q_init"
---

# q\_init(3)

initialize and free queue

## NAME

q\_init, q\_free - initialize and free queue

## LIBRARY

Librecast library (*liblibrecast*, *-llibrecast*)

## SYNOPSIS

```
#include <librecast/q.h>
```

**int q\_init(q\_t** *\*q***);** **int q\_free(q\_t** *\*q***);**

Compile and link with *-llibrecast*.

## DESCRIPTION

The **q\_init**() function initializes smolq queue *q*.

You will be surprised to learn that **q\_free**() is the corresponding function to free a queue so initialized.

## RETURN VALUE

These functions return zero on success. On error, -1 is returned and *errno* is set to indicate the error.

## ERRORS

**q\_init**() may fail when initializing the queue semaphore. **q\_free**() may fail when destroying the queue semaphore. See [**sem\_init**(3)](/sem_init/3.md) and [**sem\_destroy**(3)](/sem_destroy/3.md) for the relevant error codes.

## SEE ALSO

[**q\_job\_seek**(3)](/q_job_seek/3.md), [**q\_pool\_create**(3)](/q_pool_create/3.md), [**q\_pool\_destroy**(3)](/q_pool_destroy/3.md), [**q\_push**(3)](/q_push/3.md), [**q\_wait**(3)](/q_wait/3.md), [**sem\_init**(3)](/sem_init/3.md), [**sem\_destroy**(3)](/sem_destroy/3.md)
