Branch data Line data Source code
1 : : #include "mem.h"
2 : : #include "mem_internal.h"
3 : :
4 : : /**
5 : : * @brief Copy an exact bounded byte range into a data descriptor
6 : : *
7 : : * This helper is the raw-buffer replace counterpart of
8 : : * @ref mem_concat_buffer. It interprets @p source_buffer_size_bytes as the
9 : : * exact number of source bytes to import, resizes the destination to that
10 : : * exact payload size, and keeps the result in data mode
11 : : *
12 : : * Self-aliasing is supported when @p source_buffer points inside the current
13 : : * destination allocation. Passing `NULL` together with size 0 clears the
14 : : * destination
15 : : *
16 : : * @param destination Pointer to the destination descriptor receiving copied data
17 : : * @param source_buffer_size_bytes Exact byte count to copy from @p source_buffer
18 : : * @param source_buffer Pointer to source bytes
19 : : * @return `SUCCESS` on success; `FAILURE` otherwise
20 : : */
21 : 473 : Return mem_copy_buffer(
22 : : memory *destination,
23 : : const size_t source_buffer_size_bytes,
24 : : const void *const source_buffer)
25 : : {
26 : 473 : return(mem_core_buffer(
27 : : TRANSFER_REPLACE,
28 : : destination,
29 : : source_buffer_size_bytes,
30 : : source_buffer));
31 : : }
|