---
name: "loc_new"
section: "3"
platform: "linux"
package: "libloc"
version: "0.9.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/loc_new"
---

# loc\_new(3)

Create a new libloc context

## NAME

loc\_new - Create a new libloc context

## SYNOPSIS

```
#include <libloc/libloc.h>
```

struct loc\_ctx;

int loc\_new(struct loc\_ctx\*\* ctx);

struct loc\_ctx\* loc\_ref(struct loc\_ctx\* ctx);

struct loc\_ctx\* loc\_unref(struct loc\_ctx\* ctx);

## DESCRIPTION

Every operation in libloc requires to set up a context first. This is done by calling [loc\_new(3)](/loc_new/3.md).

Every time another part of your code is holding a reference to the context, you will need to call loc\_ref() to increase the reference counter. If you no longer need the context, you will need to call loc\_unref().

## SEE ALSO

[**libloc**(3)](/libloc/3.md)

## AUTHORS

Michael Tremer
