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

# lc\_ctx\_new(3)

create and free Librecast contexts

## NAME

lc\_ctx\_new, lc\_ctx\_free - create and free Librecast contexts

## LIBRARY

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

## SYNOPSIS

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

**lc\_ctx\_t \*lc\_ctx\_new(void);** **void lc\_ctx\_free(lc\_ctx\_t** *\*ctx***);**

Compile and link with *-llibrecast*.

## DESCRIPTION

**lc\_ctx\_new**() creates a new Librecast context and sets up the environment. Call [**lc\_ctx\_free**(3)](/lc_ctx_free/3.md) when done.

**lc\_ctx\_free**() invalidates and frees a Librecast context created with [**lc\_ctx\_new**(3)](/lc_ctx_new/3.md)

## RETURN VALUE

**lc\_ctx\_new**() returns a pointer to a *lc\_ctx\_t* handle. On error returns NULL and sets *errno* to **ENOMEM**.

The **lc\_ctx\_free**() function returns no value.

## ERRORS

**lc\_ctx\_new**() can fail with the following error:

- **ENOMEM**

  Out of memory. Possibly, the application hit the **RLIMIT\_AS** or **RLIMIT\_DATA** limit described in [**getrlimit**(2)](/getrlimit/2.md).

## EXAMPLE

### Program source

```
lc_ctx_t *lctx;
lctx = lc_ctx_new();
/* your Librecast program here */
lc_ctx_free(lctx); /* free context when done */
```

## SEE ALSO

[**lc\_ctx\_free**(3)](/lc_ctx_free/3.md)
