Metall  v0.29
A persistent memory allocator for data-centric analytics
metall.h File Reference
#include <stdbool.h>
#include <stddef.h>

Go to the source code of this file.

Typedefs

typedef struct metall_manager metall_manager
 Opaque struct representing a metall manager. More...
 

Functions

metall_managermetall_open (const char *path)
 Attempts to open the metall datastore at path. More...
 
metall_managermetall_open_read_only (const char *path)
 Attempts to open the metall datastore at path in read only mode. More...
 
metall_managermetall_create (const char *path)
 Attempts to create a metall datastore at path. More...
 
bool metall_snapshot (metall_manager *manager, const char *dst_path)
 Creates a snapshot of the metall datastore of manager and places it at dst_path. More...
 
void metall_flush (metall_manager *manager)
 Flushes the given manager. More...
 
void metall_close (metall_manager *manager)
 Closes a metall manager. More...
 
bool metall_remove (const char *path)
 Removes the metall datastore at path. More...
 
void * metall_malloc (metall_manager *manager, size_t size)
 Allocates size bytes. More...
 
void metall_free (metall_manager *manager, void *ptr)
 Frees memory previously allocated by metall_malloc. More...
 
void * metall_named_malloc (metall_manager *manager, const char *name, size_t size)
 Allocates size bytes and associates the allocated memory with a name. More...
 
void * metall_find (metall_manager *manager, const char *name)
 Finds memory that was previously allocated using metall_named_alloc. More...
 
bool metall_named_free (metall_manager *manager, const char *name)
 Frees memory previously allocated by metall_named_malloc. More...
 

Typedef Documentation

◆ metall_manager

Opaque struct representing a metall manager.

Note
this type is internally represented by metall::manager therefore pointers to metall_manager may be reinterpret-casted to pointers to metall::manager

Function Documentation

◆ metall_open()

metall_manager* metall_open ( const char *  path)

Attempts to open the metall datastore at path.

Parameters
pathpath to datastore
Returns
true on success, false on failure. On failure, sets errno to one of the following values:
  • ENOTRECOVERABLE if the given metall datastore is inconsistent
Examples
c_api.c.

◆ metall_open_read_only()

metall_manager* metall_open_read_only ( const char *  path)

Attempts to open the metall datastore at path in read only mode.

Parameters
pathpath to datastore
Returns
true on success, false on failure. On failure, sets errno to one of the following values:
  • ENOTRECOVERABLE if the given metall datastore is inconsistent

◆ metall_create()

metall_manager* metall_create ( const char *  path)

Attempts to create a metall datastore at path.

Parameters
pathpath at which to create a datastore
Returns
true on success, false on failure. On failure, sets errno to one of the following values:
  • EEXIST if the given path already exists
  • ENOTRECOVERABLE if the datastore could not be created for some other reason
Examples
c_api.c.

◆ metall_snapshot()

bool metall_snapshot ( metall_manager manager,
const char *  dst_path 
)

Creates a snapshot of the metall datastore of manager and places it at dst_path.

Parameters
managermanager to perform snapshot
dst_pathpath where to place the snapshot
Returns
true if the snapshot was successfully created otherwise false.
Examples
c_api.c.

◆ metall_flush()

void metall_flush ( metall_manager manager)

Flushes the given manager.

Parameters
managermanager to flush
Examples
c_api.c.

◆ metall_close()

void metall_close ( metall_manager manager)

Closes a metall manager.

Examples
c_api.c.

◆ metall_remove()

bool metall_remove ( const char *  path)

Removes the metall datastore at path.

Parameters
pathpath to datastore to remove
Returns
true on successful removal, false otherwise. On failure, sets errno to one of the following values:
  • EADDRINUSE if there is a metall manager open for the given path
Warning
Behaviour is undefined if there is still a metall manager for path open
Examples
c_api.c.

◆ metall_malloc()

void* metall_malloc ( metall_manager manager,
size_t  size 
)

Allocates size bytes.

Parameters
managermanager to allocate with
sizenumber of bytes to allocate
Returns
pointer to allocated memory if successful otherwise returns NULL and sets errno to one of the following values
  • EINVAL
Examples
c_api.c.

◆ metall_free()

void metall_free ( metall_manager manager,
void *  ptr 
)

Frees memory previously allocated by metall_malloc.

Parameters
managermanager from which to free
ptrmemory to free
Examples
c_api.c.

◆ metall_named_malloc()

void* metall_named_malloc ( metall_manager manager,
const char *  name,
size_t  size 
)

Allocates size bytes and associates the allocated memory with a name.

Parameters
managermanager to allocate with
nameA name of the allocated memory
sizenumber of bytes to allocate
Returns
pointer to the allocated memory if sucessful otherwise returns NULL and sets errno to one of the following values
  • EINVAL if the given path does not have a metall datastore open
  • ENOMEM if the memory could not be allocated
Examples
c_api.c.

◆ metall_find()

void* metall_find ( metall_manager manager,
const char *  name 
)

Finds memory that was previously allocated using metall_named_alloc.

Parameters
managermanager to find the object in
namename of the allocated memory to find
Returns
pointer to the allocated memory if found. Otherwise, returns NULL and sets errno to one of the following values
  • EINVAL if the given path does not have a metall datastore open
  • ENOTENT if the object could not be found
Examples
c_api.c.

◆ metall_named_free()

bool metall_named_free ( metall_manager manager,
const char *  name 
)

Frees memory previously allocated by metall_named_malloc.

Parameters
managermanager from which to free
namename of the allocated memory to free
Returns
true if sucessfully freed, otherwise returns false and sets errno to one of the following values
  • EINVAL if the given path does not have a metall datastore open
  • ENOENT if the referred to object does not exist
Examples
c_api.c.