#include "ckernel_concat_i32.h"
#include <stdint.h>
#include <string.h>
Go to the source code of this file.
|
| int | ck_concat_i32_checked (const int32_t *left, size_t left_elements, size_t left_count, const int32_t *right, size_t right_elements, size_t right_count, int32_t *output, size_t output_elements) |
| static int | overlaps (const int32_t *left, size_t left_count, const int32_t *right, size_t right_count) |
| static int | valid_region (const int32_t *pointer, size_t elements) |
◆ ck_concat_i32_checked()
| int ck_concat_i32_checked |
( |
const int32_t * | left, |
|
|
size_t | left_elements, |
|
|
size_t | left_count, |
|
|
const int32_t * | right, |
|
|
size_t | right_elements, |
|
|
size_t | right_count, |
|
|
int32_t * | output, |
|
|
size_t | output_elements ) |
Definition at line 20 of file concat_i32_checked.c.
23 {
24 if (!left_count || !right_count || left_count > SIZE_MAX - right_count ||
25 left_count > left_elements || right_count > right_elements ||
26 left_count + right_count > output_elements)
27 return -2;
30 overlaps(
left, left_count, output, left_count + right_count) ||
31 overlaps(
right, right_count, output, left_count + right_count))
32 return -1;
33 memcpy(output,
left, left_count *
sizeof(int32_t));
34 memcpy(output + left_count,
right, right_count *
sizeof(int32_t));
35 return 0;
36}
static int overlaps(const int32_t *left, size_t left_count, const int32_t *right, size_t right_count)
static int valid_region(const int32_t *pointer, size_t elements)
const char const char * right
References left, overlaps(), right, and valid_region().
◆ overlaps()
| int overlaps |
( |
const int32_t * | left, |
|
|
size_t | left_count, |
|
|
const int32_t * | right, |
|
|
size_t | right_count ) |
|
static |
◆ valid_region()
| int valid_region |
( |
const int32_t * | pointer, |
|
|
size_t | elements ) |
|
static |
Definition at line 6 of file concat_i32_checked.c.
6 {
7 return pointer && (uintptr_t)pointer % _Alignof(int32_t) == 0 &&
8 elements <= SIZE_MAX / sizeof(int32_t) &&
9 (uintptr_t)pointer <= UINTPTR_MAX - elements * sizeof(int32_t);
10}
Referenced by ck_concat_i32_checked().