Scroll to navigation

LC_MEMSYNC(3) Librecast Programmer's Manual LC_MEMSYNC(3)


lc_memsync - synchronize two memory areas


Librecast library (liblibrecast, -llibrecast)


#include <librecast/sync.h>
int lc_memsync(void *dst, void *src, const size_t n, q_t *q
               lc_stat_t *stats, lc_sync_options_t *opt, int flags);

Compile and link with -llibrecast.


The lc_memsync function synchronizes two non-overlapping memory areas of size n bytes using merkle tree comparison, overwriting dst with bytes from src.

If q is not NULL, it must point to a queue q_t structure previously initialized with q_init(3). This queue will have jobs enqueued to build the trees. This is normally used in conjunction with a threadpool created with q_pool_create(3) with threads all calling q_job_seek(3).

If q is NULL, the creation and destruction of a queue and threadpool will be handled automatically.

If stats is not NULL, transfer statistics will be returned in this structure.

opt is not used, at present, and must be NULL for compatibility with future versions.

flags is not used, at present, and must be zero for compatibility with future versions.


lc_memsync() returns zero on success. On error, -1 is returned, and errno is set to indicate the error.


Invalid argument.

ENOMEM Not enough space/cannot allocate memory (POSIX.1-2001).


q_init(3), q_free(3), q_pool_create(3)

2023-08-02 LIBRECAST