← Back to C-Kernel-Engine Docs Doxygen Source Documentation
Loading...
Searching...
No Matches
ckernel_copy_i32_span.h File Reference
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Functions

int ck_copy_i32_span_checked (const int32_t *source, size_t source_elements, size_t source_offset, int32_t *destination, size_t destination_elements, size_t destination_offset, size_t count)

Function Documentation

◆ ck_copy_i32_span_checked()

int ck_copy_i32_span_checked ( const int32_t * source,
size_t source_elements,
size_t source_offset,
int32_t * destination,
size_t destination_elements,
size_t destination_offset,
size_t count )

Definition at line 11 of file copy_i32_span_checked.c.

14 {
15 if (!count || source_offset > source_elements ||
16 count > source_elements - source_offset ||
17 destination_offset > destination_elements ||
18 count > destination_elements - destination_offset)
19 return -2;
20 if (!valid_region(source, source_elements) ||
21 !valid_region(destination, destination_elements))
22 return -1;
23 const uintptr_t src = (uintptr_t)(source + source_offset);
24 const uintptr_t dst = (uintptr_t)(destination + destination_offset);
25 const size_t bytes = count * sizeof(int32_t);
26 if (src < dst + bytes && dst < src + bytes)
27 return -1;
28 memcpy(destination + destination_offset, source + source_offset, bytes);
29 return 0;
30}
static int valid_region(const int32_t *pointer, size_t elements)
const uint8_t size_t count
Definition true_bpe.h:211

References count, and valid_region().