Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Side by Side Diff: nss/lib/base/libc.c

Issue 1843333003: Update NSPR to 4.12 and NSS to 3.23 on iOS (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/nss.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* This Source Code Form is subject to the terms of the Mozilla Public 1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 4
5 /* 5 /*
6 * libc.c 6 * libc.c
7 * 7 *
8 * This file contains our wrappers/reimplementations for "standard" 8 * This file contains our wrappers/reimplementations for "standard"
9 * libc functions. Things like "memcpy." We add to this as we need 9 * libc functions. Things like "memcpy." We add to this as we need
10 * it. Oh, and let's keep it in alphabetical order, should it ever 10 * it. Oh, and let's keep it in alphabetical order, should it ever
11 * get large. Most string/character stuff should be in utf8.c, not 11 * get large. Most string/character stuff should be in utf8.c, not
12 * here. This file (and maybe utf8.c) should be the only ones in 12 * here. This file (and maybe utf8.c) should be the only ones in
13 * NSS to include files with angle brackets. 13 * NSS to include files with angle brackets.
14 */ 14 */
15 15
16 #ifndef BASE_H 16 #ifndef BASE_H
17 #include "base.h" 17 #include "base.h"
18 #endif /* BASE_H */ 18 #endif /* BASE_H */
19 19
20 #include <string.h> /* memcpy, memset */ 20 #include <string.h> /* memcpy, memset */
21 21
22 /* 22 /*
23 * nsslibc_memcpy 23 * nsslibc_memcpy
24 * nsslibc_memset 24 * nsslibc_memset
25 * nsslibc_offsetof 25 * nsslibc_offsetof
26 * nsslibc_memequal 26 * nsslibc_memequal
27 */ 27 */
28 28
29 /* 29 /*
30 * nsslibc_memcpy 30 * nsslibc_memcpy
31 * 31 *
32 * Errors: 32 * Errors:
33 * NSS_ERROR_INVALID_POINTER 33 * NSS_ERROR_INVALID_POINTER
34 * 34 *
35 * Return value: 35 * Return value:
36 * NULL on error 36 * NULL on error
37 * The destination pointer on success 37 * The destination pointer on success
38 */ 38 */
39 39
40 NSS_IMPLEMENT void * 40 NSS_IMPLEMENT void *
41 nsslibc_memcpy 41 nsslibc_memcpy(void *dest, const void *source, PRUint32 n)
42 (
43 void *dest,
44 const void *source,
45 PRUint32 n
46 )
47 { 42 {
48 #ifdef NSSDEBUG 43 #ifdef NSSDEBUG
49 if( ((void *)NULL == dest) || ((const void *)NULL == source) ) { 44 if (((void *)NULL == dest) || ((const void *)NULL == source)) {
50 nss_SetError(NSS_ERROR_INVALID_POINTER); 45 nss_SetError(NSS_ERROR_INVALID_POINTER);
51 return (void *)NULL; 46 return (void *)NULL;
52 } 47 }
53 #endif /* NSSDEBUG */ 48 #endif /* NSSDEBUG */
54 49
55 return memcpy(dest, source, (size_t)n); 50 return memcpy(dest, source, (size_t)n);
56 } 51 }
57 52
58 /* 53 /*
59 * nsslibc_memset 54 * nsslibc_memset
60 * 55 *
61 * Errors: 56 * Errors:
62 * NSS_ERROR_INVALID_POINTER 57 * NSS_ERROR_INVALID_POINTER
63 * 58 *
64 * Return value: 59 * Return value:
65 * NULL on error 60 * NULL on error
66 * The destination pointer on success 61 * The destination pointer on success
67 */ 62 */
68 63
69 NSS_IMPLEMENT void * 64 NSS_IMPLEMENT void *
70 nsslibc_memset 65 nsslibc_memset(void *dest, PRUint8 byte, PRUint32 n)
71 (
72 void *dest,
73 PRUint8 byte,
74 PRUint32 n
75 )
76 { 66 {
77 #ifdef NSSDEBUG 67 #ifdef NSSDEBUG
78 if( ((void *)NULL == dest) ) { 68 if (((void *)NULL == dest)) {
79 nss_SetError(NSS_ERROR_INVALID_POINTER); 69 nss_SetError(NSS_ERROR_INVALID_POINTER);
80 return (void *)NULL; 70 return (void *)NULL;
81 } 71 }
82 #endif /* NSSDEBUG */ 72 #endif /* NSSDEBUG */
83 73
84 return memset(dest, (int)byte, (size_t)n); 74 return memset(dest, (int)byte, (size_t)n);
85 } 75 }
86 76
87 /* 77 /*
88 * nsslibc_memequal 78 * nsslibc_memequal
89 * 79 *
90 * Errors: 80 * Errors:
91 * NSS_ERROR_INVALID_POINTER 81 * NSS_ERROR_INVALID_POINTER
92 * 82 *
93 * Return value: 83 * Return value:
94 * PR_TRUE if they match 84 * PR_TRUE if they match
95 * PR_FALSE if they don't 85 * PR_FALSE if they don't
96 * PR_FALSE upon error 86 * PR_FALSE upon error
97 */ 87 */
98 88
99 NSS_IMPLEMENT PRBool 89 NSS_IMPLEMENT PRBool
100 nsslibc_memequal 90 nsslibc_memequal(const void *a, const void *b, PRUint32 len,
101 ( 91 PRStatus *statusOpt)
102 const void *a,
103 const void *b,
104 PRUint32 len,
105 PRStatus *statusOpt
106 )
107 { 92 {
108 #ifdef NSSDEBUG 93 #ifdef NSSDEBUG
109 if( (((void *)NULL == a) || ((void *)NULL == b)) ) { 94 if ((((void *)NULL == a) || ((void *)NULL == b))) {
110 nss_SetError(NSS_ERROR_INVALID_POINTER); 95 nss_SetError(NSS_ERROR_INVALID_POINTER);
111 if( (PRStatus *)NULL != statusOpt ) { 96 if ((PRStatus *)NULL != statusOpt) {
112 *statusOpt = PR_FAILURE; 97 *statusOpt = PR_FAILURE;
98 }
99 return PR_FALSE;
113 } 100 }
114 return PR_FALSE;
115 }
116 #endif /* NSSDEBUG */ 101 #endif /* NSSDEBUG */
117 102
118 if( (PRStatus *)NULL != statusOpt ) { 103 if ((PRStatus *)NULL != statusOpt) {
119 *statusOpt = PR_SUCCESS; 104 *statusOpt = PR_SUCCESS;
120 } 105 }
121 106
122 if( 0 == memcmp(a, b, len) ) { 107 if (0 == memcmp(a, b, len)) {
123 return PR_TRUE; 108 return PR_TRUE;
124 } else { 109 } else {
125 return PR_FALSE; 110 return PR_FALSE;
126 } 111 }
127 } 112 }
128 113
129 /* 114 /*
130 * nsslibc_memcmp 115 * nsslibc_memcmp
131 */ 116 */
132 117
133 NSS_IMPLEMENT PRInt32 118 NSS_IMPLEMENT PRInt32
134 nsslibc_memcmp 119 nsslibc_memcmp(const void *a, const void *b, PRUint32 len, PRStatus *statusOpt)
135 (
136 const void *a,
137 const void *b,
138 PRUint32 len,
139 PRStatus *statusOpt
140 )
141 { 120 {
142 int v; 121 int v;
143 122
144 #ifdef NSSDEBUG 123 #ifdef NSSDEBUG
145 if( (((void *)NULL == a) || ((void *)NULL == b)) ) { 124 if ((((void *)NULL == a) || ((void *)NULL == b))) {
146 nss_SetError(NSS_ERROR_INVALID_POINTER); 125 nss_SetError(NSS_ERROR_INVALID_POINTER);
147 if( (PRStatus *)NULL != statusOpt ) { 126 if ((PRStatus *)NULL != statusOpt) {
148 *statusOpt = PR_FAILURE; 127 *statusOpt = PR_FAILURE;
128 }
129 return -2;
149 } 130 }
150 return -2;
151 }
152 #endif /* NSSDEBUG */ 131 #endif /* NSSDEBUG */
153 132
154 if( (PRStatus *)NULL != statusOpt ) { 133 if ((PRStatus *)NULL != statusOpt) {
155 *statusOpt = PR_SUCCESS; 134 *statusOpt = PR_SUCCESS;
156 } 135 }
157 136
158 v = memcmp(a, b, len); 137 v = memcmp(a, b, len);
159 return (PRInt32)v; 138 return (PRInt32)v;
160 } 139 }
161 140
162 /* 141 /*
163 * offsetof is a preprocessor definition 142 * offsetof is a preprocessor definition
164 */ 143 */
OLDNEW
« no previous file with comments | « nss/lib/base/item.c ('k') | nss/lib/base/list.c » ('j') | nss/lib/util/secoid.c » ('J')

Powered by Google App Engine
This is Rietveld 408576698