Branch data Line data Source code
1 : : /*
2 : : * SPDX-License-Identifier: MIT
3 : : * Copyright (c) 2024 IUPAC and InChI Trust
4 : : */
5 : :
6 : : /* djb-rwth: implementation of missing bounds - checking functions */
7 : :
8 : : #include <stdio.h>
9 : : #include <stdlib.h>
10 : : #include <string.h>
11 : : #include <errno.h>
12 : : #include "ichirvrs.h"
13 : : #include "bcf_s.h"
14 : :
15 : 0 : int max_3(int a, int b, int c)
16 : : {
17 [ # # # # ]: 0 : if ((a > b) && (a > c))
18 : 0 : return a;
19 [ # # # # ]: 0 : else if ((b > a) && (b > c))
20 : 0 : return b;
21 : : else
22 : 0 : return c;
23 : : }
24 : :
25 : 0 : int memcpy_custom(char** dst, char* src, unsigned long long len)
26 : : {
27 : 0 : char* dst_local = (char*)calloc(len, sizeof(char));
28 : 0 : char* src_local = src;
29 : : int k;
30 : :
31 [ # # ]: 0 : if (dst_local)
32 : : {
33 : 0 : *dst = dst_local;
34 [ # # ]: 0 : for (k = 0; k < len; k++)
35 : : {
36 : 0 : dst_local[k] = src_local[k];
37 : : }
38 : : }
39 : : else
40 : : {
41 : 0 : free(dst_local);
42 : 0 : free(src_local);
43 : 0 : return RI_ERR_ALLOC;
44 : : }
45 : 0 : return 0;
46 : : }
|