.TH LC_MEMSYNC 3 2023-08-02 "LIBRECAST" "Librecast Programmer's Manual" .SH NAME lc_memsync \- synchronize two memory areas .SH LIBRARY Librecast library .RI ( liblibrecast ", " \-llibrecast ) .SH SYNOPSIS .nf .B #include .PP .BI "int lc_memsync(void " *dst ", void " *src ", const size_t " n ", q_t " *q " .BI " lc_stat_t " *stats ", lc_sync_options_t " *opt ", int " flags ");" .fi .PP Compile and link with \fI\-llibrecast\fP. .SH DESCRIPTION The .BR lc_memsync function synchronizes two non-overlapping memory areas of size .IR n bytes using merkle tree comparison, overwriting .IR dst with bytes from .IR src . .PP If .IR q is not NULL, it must point to a queue .IR q_t structure previously initialized with .BR q_init (3). This queue will have jobs enqueued to build the trees. This is normally used in conjunction with a threadpool created with .BR q_pool_create (3) with threads all calling .BR q_job_seek (3). .PP If .IR q is NULL, the creation and destruction of a queue and threadpool will be handled automatically. .PP If .IR stats is not NULL, transfer statistics will be returned in this structure. .PP .IR opt is not used, at present, and must be NULL for compatibility with future versions. .PP .IR flags is not used, at present, and must be zero for compatibility with future versions. .PP .SH RETURN VALUE .BR lc_memsync () returns zero on success. On error, \-1 is returned, and .I errno is set to indicate the error. .SH ERRORS .TP .BR EINVAL Invalid argument. .PP .BR ENOMEM Not enough space/cannot allocate memory (POSIX.1-2001). .PP .SH SEE ALSO .BR q_init (3), .BR q_free (3), .BR q_pool_create (3)