---
name: "loc_database_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_database_new"
---

# loc\_database\_new(3)

Create a new libloc context

## NAME

loc\_database\_new - Create a new libloc context

## SYNOPSIS

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

struct loc\_database;

int loc\_database\_new(struct loc\_ctx\* ctx, struct loc\_database\*\* database, FILE\* f);

Reference Counting:

struct loc\_database\* loc\_database\_ref(struct loc\_database\* db);

struct loc\_database\* loc\_database\_unref(struct loc\_database\* db);

Access some data:

time\_t loc\_database\_created\_at(struct loc\_database\* db);

const char\* loc\_database\_get\_vendor(struct loc\_database\* db);

const char\* loc\_database\_get\_description(struct loc\_database\* db);

const char\* loc\_database\_get\_license(struct loc\_database\* db);

## DESCRIPTION

loc\_database\_new() opens a new database from the given file descriptor. The file descriptor can be closed after this operation because the function is creating its own copy.

If the database could be opened successfully, zero is returned. Otherwise a non-zero return code will indicate an error and errno will be set appropriately.

Various meta-data about the database can be retrieved with loc\_database\_created\_at(), loc\_database\_get\_vendor(), loc\_database\_get\_description(), and loc\_database\_get\_license().

## SEE ALSO

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

## AUTHORS

Michael Tremer
