comparison nss/lib/base/nssbase.h @ 0:1e5118fa0cb1

This is NSS with a Cmake Buildsyste To compile a static NSS library for Windows we've used the Chromium-NSS fork and added a Cmake buildsystem to compile it statically for Windows. See README.chromium for chromium changes and README.trustbridge for our modifications.
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 28 Jul 2014 10:47:06 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1e5118fa0cb1
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
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 #ifndef NSSBASE_H
6 #define NSSBASE_H
7
8 /*
9 * nssbase.h
10 *
11 * This header file contains the prototypes of the basic public
12 * NSS routines.
13 */
14
15 #ifndef NSSBASET_H
16 #include "nssbaset.h"
17 #endif /* NSSBASET_H */
18
19 PR_BEGIN_EXTERN_C
20
21 /*
22 * NSSArena
23 *
24 * The public methods relating to this type are:
25 *
26 * NSSArena_Create -- constructor
27 * NSSArena_Destroy
28 * NSS_ZAlloc
29 * NSS_ZRealloc
30 * NSS_ZFreeIf
31 */
32
33 /*
34 * NSSArena_Create
35 *
36 * This routine creates a new memory arena. This routine may return
37 * NULL upon error, in which case it will have created an error stack.
38 *
39 * The top-level error may be one of the following values:
40 * NSS_ERROR_NO_MEMORY
41 *
42 * Return value:
43 * NULL upon error
44 * A pointer to an NSSArena upon success
45 */
46
47 NSS_EXTERN NSSArena *
48 NSSArena_Create
49 (
50 void
51 );
52
53 extern const NSSError NSS_ERROR_NO_MEMORY;
54
55 /*
56 * NSSArena_Destroy
57 *
58 * This routine will destroy the specified arena, freeing all memory
59 * allocated from it. This routine returns a PRStatus value; if
60 * successful, it will return PR_SUCCESS. If unsuccessful, it will
61 * create an error stack and return PR_FAILURE.
62 *
63 * The top-level error may be one of the following values:
64 * NSS_ERROR_INVALID_ARENA
65 *
66 * Return value:
67 * PR_SUCCESS upon success
68 * PR_FAILURE upon failure
69 */
70
71 NSS_EXTERN PRStatus
72 NSSArena_Destroy
73 (
74 NSSArena *arena
75 );
76
77 extern const NSSError NSS_ERROR_INVALID_ARENA;
78
79 /*
80 * The error stack
81 *
82 * The public methods relating to the error stack are:
83 *
84 * NSS_GetError
85 * NSS_GetErrorStack
86 */
87
88 /*
89 * NSS_GetError
90 *
91 * This routine returns the highest-level (most general) error set
92 * by the most recent NSS library routine called by the same thread
93 * calling this routine.
94 *
95 * This routine cannot fail. It may return NSS_ERROR_NO_ERROR, which
96 * indicates that the previous NSS library call did not set an error.
97 *
98 * Return value:
99 * 0 if no error has been set
100 * A nonzero error number
101 */
102
103 NSS_EXTERN NSSError
104 NSS_GetError
105 (
106 void
107 );
108
109 extern const NSSError NSS_ERROR_NO_ERROR;
110
111 /*
112 * NSS_GetErrorStack
113 *
114 * This routine returns a pointer to an array of NSSError values,
115 * containingthe entire sequence or "stack" of errors set by the most
116 * recent NSS library routine called by the same thread calling this
117 * routine. NOTE: the caller DOES NOT OWN the memory pointed to by
118 * the return value. The pointer will remain valid until the calling
119 * thread calls another NSS routine. The lowest-level (most specific)
120 * error is first in the array, and the highest-level is last. The
121 * array is zero-terminated. This routine may return NULL upon error;
122 * this indicates a low-memory situation.
123 *
124 * Return value:
125 * NULL upon error, which is an implied NSS_ERROR_NO_MEMORY
126 * A NON-caller-owned pointer to an array of NSSError values
127 */
128
129 NSS_EXTERN NSSError *
130 NSS_GetErrorStack
131 (
132 void
133 );
134
135 /*
136 * NSS_ZNEW
137 *
138 * This preprocessor macro will allocate memory for a new object
139 * of the specified type with nss_ZAlloc, and will cast the
140 * return value appropriately. If the optional arena argument is
141 * non-null, the memory will be obtained from that arena; otherwise,
142 * the memory will be obtained from the heap. This routine may
143 * return NULL upon error, in which case it will have set an error
144 * upon the error stack.
145 *
146 * The error may be one of the following values:
147 * NSS_ERROR_INVALID_ARENA
148 * NSS_ERROR_NO_MEMORY
149 *
150 * Return value:
151 * NULL upon error
152 * A pointer to the new segment of zeroed memory
153 */
154
155 /* The following line exceeds 72 characters, but emacs barfs if we split it. */
156 #define NSS_ZNEW(arenaOpt, type) ((type *)NSS_ZAlloc((arenaOpt), sizeof(type)))
157
158 /*
159 * NSS_ZNEWARRAY
160 *
161 * This preprocessor macro will allocate memory for an array of
162 * new objects, and will cast the return value appropriately.
163 * If the optional arena argument is non-null, the memory will
164 * be obtained from that arena; otherwise, the memory will be
165 * obtained from the heap. This routine may return NULL upon
166 * error, in which case it will have set an error upon the error
167 * stack. The array size may be specified as zero.
168 *
169 * The error may be one of the following values:
170 * NSS_ERROR_INVALID_ARENA
171 * NSS_ERROR_NO_MEMORY
172 *
173 * Return value:
174 * NULL upon error
175 * A pointer to the new segment of zeroed memory
176 */
177
178 /* The following line exceeds 72 characters, but emacs barfs if we split it. */
179 #define NSS_ZNEWARRAY(arenaOpt, type, quantity) ((type *)NSS_ZAlloc((arenaOpt), sizeof(type) * (quantity)))
180
181
182 /*
183 * NSS_ZAlloc
184 *
185 * This routine allocates and zeroes a section of memory of the
186 * size, and returns to the caller a pointer to that memory. If
187 * the optional arena argument is non-null, the memory will be
188 * obtained from that arena; otherwise, the memory will be obtained
189 * from the heap. This routine may return NULL upon error, in
190 * which case it will have set an error upon the error stack. The
191 * value specified for size may be zero; in which case a valid
192 * zero-length block of memory will be allocated. This block may
193 * be expanded by calling NSS_ZRealloc.
194 *
195 * The error may be one of the following values:
196 * NSS_ERROR_INVALID_ARENA
197 * NSS_ERROR_NO_MEMORY
198 * NSS_ERROR_ARENA_MARKED_BY_ANOTHER_THREAD
199 *
200 * Return value:
201 * NULL upon error
202 * A pointer to the new segment of zeroed memory
203 */
204
205 NSS_EXTERN void *
206 NSS_ZAlloc
207 (
208 NSSArena *arenaOpt,
209 PRUint32 size
210 );
211
212 /*
213 * NSS_ZRealloc
214 *
215 * This routine reallocates a block of memory obtained by calling
216 * nss_ZAlloc or nss_ZRealloc. The portion of memory
217 * between the new and old sizes -- which is either being newly
218 * obtained or released -- is in either case zeroed. This routine
219 * may return NULL upon failure, in which case it will have placed
220 * an error on the error stack.
221 *
222 * The error may be one of the following values:
223 * NSS_ERROR_INVALID_POINTER
224 * NSS_ERROR_NO_MEMORY
225 * NSS_ERROR_ARENA_MARKED_BY_ANOTHER_THREAD
226 *
227 * Return value:
228 * NULL upon error
229 * A pointer to the replacement segment of memory
230 */
231
232 NSS_EXTERN void *
233 NSS_ZRealloc
234 (
235 void *pointer,
236 PRUint32 newSize
237 );
238
239
240 /*
241 * NSS_ZFreeIf
242 *
243 * If the specified pointer is non-null, then the region of memory
244 * to which it points -- which must have been allocated with
245 * nss_ZAlloc -- will be zeroed and released. This routine
246 * returns a PRStatus value; if successful, it will return PR_SUCCESS.
247 * If unsuccessful, it will set an error on the error stack and return
248 * PR_FAILURE.
249 *
250 * The error may be one of the following values:
251 * NSS_ERROR_INVALID_POINTER
252 *
253 * Return value:
254 * PR_SUCCESS
255 * PR_FAILURE
256 */
257
258 NSS_EXTERN PRStatus
259 NSS_ZFreeIf
260 (
261 void *pointer
262 );
263
264 PR_END_EXTERN_C
265
266 #endif /* NSSBASE_H */
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)