liberasurecode 1.8.0
Erasure Code API library
Loading...
Searching...
No Matches
Functions
erasurecode_helpers.c File Reference
#include <assert.h>
#include <stdio.h>
#include <stdarg.h>
#include <zlib.h>
#include "erasurecode_backend.h"
#include "erasurecode_helpers.h"
#include "erasurecode_helpers_ext.h"
#include "erasurecode_stdinc.h"
#include "erasurecode_version.h"
#include "alg_sig.h"
#include "erasurecode_log.h"

Go to the source code of this file.

Functions

static bool is_fragment (char *buf)
 
 __attribute__ ((visibility("internal")))
 Memory Management Methods.
 
void * alloc_and_set_buffer (int size, int value)
 Allocate a buffer of a specific size and set its' contents to the specified value.
 
char * get_data_ptr_from_fragment (char *buf)
 
int get_libec_version (char *buf, uint32_t *ver)
 
int get_backend_id (char *buf, ec_backend_id_t *id)
 
int get_backend_version (char *buf, uint32_t *version)
 

Function Documentation

◆ __attribute__()

__attribute__ ( (visibility("internal"))  )

Memory Management Methods.

Compute a size aligned to the number of data and the underlying wordsize of the EC algorithm.

Return total fragment length (on-disk, on-wire)

Deallocate memory buffer if it's not NULL.

Allocate a zero-ed buffer of a specific size.

The following methods provide wrappers for allocating and deallocating memory.

Parameters
sizeinteger size in bytes of buffer to allocate
Returns
pointer to start of allocated buffer or NULL on error

This methods returns NULL so that you can free and reset a buffer using a single line as follows:

my_ptr = check_and_free_buffer(my_ptr);

Returns
NULL
Parameters
buf- pointer to fragment buffer
Returns
fragment size on disk
Parameters
instance- ec_backend_t instance (to extract args)
data_len- integer length of data in bytes
Returns
integer data length aligned with wordsize of EC algorithm

Ensure all memory is aligned to 16-byte boundaries to support 128-bit operations

Definition at line 61 of file erasurecode_helpers.c.

◆ alloc_and_set_buffer()

void * alloc_and_set_buffer ( int  size,
int  value 
)

Allocate a buffer of a specific size and set its' contents to the specified value.

Parameters
sizeinteger size in bytes of buffer to allocate
value
Returns
pointer to start of allocated buffer or NULL on error

Definition at line 99 of file erasurecode_helpers.c.

Referenced by liberasurecode_decode(), and liberasurecode_reconstruct_fragment().

◆ get_backend_id()

int get_backend_id ( char *  buf,
ec_backend_id_t *  id 
)

Definition at line 452 of file erasurecode_helpers.c.

References is_fragment().

◆ get_backend_version()

int get_backend_version ( char *  buf,
uint32_t *  version 
)

Definition at line 473 of file erasurecode_helpers.c.

References is_fragment().

◆ get_data_ptr_from_fragment()

char * get_data_ptr_from_fragment ( char *  buf)

Definition at line 218 of file erasurecode_helpers.c.

Referenced by __attribute__(), and liberasurecode_get_fragment_metadata().

◆ get_libec_version()

int get_libec_version ( char *  buf,
uint32_t *  ver 
)

Definition at line 431 of file erasurecode_helpers.c.

References is_fragment().

Referenced by is_invalid_fragment().

◆ is_fragment()

static bool is_fragment ( char *  buf)
static

Definition at line 43 of file erasurecode_helpers.c.

Referenced by get_backend_id(), get_backend_version(), and get_libec_version().