File Coverage

inc/matrixssl-3-9-3-open/core/psUtil.c
Criterion Covered Total %
statement 0 38 0.0
branch 0 16 0.0
condition n/a
subroutine n/a
pod n/a
total 0 54 0.0


line stmt bran cond sub pod time code
1             /**
2             * @file psUtil.c
3             * @version 950bba4 (HEAD -> master)
4             *
5             * Useful utility macros and functions. These macros and functions
6             * are intended to allow easier use of common idioms and to provide
7             * simple extensions to functions provided by C language standard.
8             *
9             * These macros and functions can be used in programs using SafeZone
10             * and MatrixSSL software or related software components.
11             */
12             /*
13             * Copyright (c) 2017 INSIDE Secure Corporation
14             * All Rights Reserved
15             *
16             * The latest version of this code is available at http://www.matrixssl.org
17             *
18             * This software is open source; you can redistribute it and/or modify
19             * it under the terms of the GNU General Public License as published by
20             * the Free Software Foundation; either version 2 of the License, or
21             * (at your option) any later version.
22             *
23             * This General Public License does NOT permit incorporating this software
24             * into proprietary programs. If you are unable to comply with the GPL, a
25             * commercial license for this software may be purchased from INSIDE at
26             * http://www.insidesecure.com/
27             *
28             * This program is distributed in WITHOUT ANY WARRANTY; without even the
29             * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
30             * See the GNU General Public License for more details.
31             *
32             * You should have received a copy of the GNU General Public License
33             * along with this program; if not, write to the Free Software
34             * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35             * http://www.gnu.org/copyleft/gpl.html
36             */
37             /******************************************************************************/
38              
39             #include "osdep.h"
40             #include "psUtil.h"
41              
42             /* Initialize memory with specified value.
43             This call is never optimized out by the compiler. */
44 0           void *psMemsetSR(void *s, int c, psSizeL_t n)
45             {
46 0 0         if (s)
47             {
48 0           memset_s(s, n, c, n);
49             }
50 0           return s;
51             }
52              
53             /* Initialize memory with zero value.
54             This call is never optimized out by the compiler. */
55 0           void *psMemzeroSR(void *s, psSizeL_t n)
56             {
57 0 0         if (s)
58             {
59 0           memset_s(s, n, 0x00, n);
60             }
61 0           return s;
62             }
63              
64             /* Initialize memory with specified value.
65             This call is never optimized out by the compiler. */
66 0           void psMemsetS(void *s, int c, psSizeL_t n)
67             {
68 0 0         if (s)
69             {
70 0           memset_s(s, n, c, n);
71             }
72 0           }
73              
74             /* Initialize memory with zero value.
75             This call is never optimized out by the compiler. */
76 0           void psMemzeroS(void *s, psSizeL_t n)
77             {
78 0 0         if (s)
79             {
80 0           memset_s(s, n, 0x00, n);
81             }
82 0           }
83              
84             /* Initialize memory with specified value.
85             This call is never optimized out by the compiler. */
86 0           void *psMemsetSRR(void *s, int c, psSizeL_t n, void *ret)
87             {
88 0 0         if (s)
89             {
90 0           memset_s(s, n, c, n);
91             }
92 0           return ret;
93             }
94              
95             /* Initialize memory with zero value.
96             This call is never optimized out by the compiler. */
97 0           void *psMemzeroSRR(void *s, psSizeL_t n, void *ret)
98             {
99 0 0         if (s)
100             {
101 0           memset_s(s, n, 0x00, n);
102             }
103 0           return ret;
104             }
105              
106 0           char *psStrdupN(const char *string)
107             {
108             size_t len;
109             char *new_str;
110              
111 0 0         if (string == NULL)
112             {
113 0           return NULL;
114             }
115 0           len = psStrlen(string) + 1;
116 0           new_str = psMallocN(len);
117 0 0         if (new_str)
118             {
119 0           psMemcpy(new_str, string, len);
120             }
121 0           return new_str;
122             }
123              
124 0           void psFreeN(void *ptr)
125             {
126 0           psFreeNoPool(ptr);
127 0           }
128              
129             /* Call free function and return specified return value. */
130 0           void *psFreeFRR(void (*free_func)(void *ptr), void *ptr, void *ret)
131             {
132 0           free_func(ptr);
133 0           return ret;
134             }
135              
136             /* end of file psUtil.c */