Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/lib/lib.c @ 1314:bd8e8495c7b3 HEAD
compile warning fix
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 22 Mar 2003 21:13:31 +0200 |
parents | c4fa748b9f24 |
children | 9df02b1533b3 |
rev | line source |
---|---|
0 | 1 /* |
2 lib.c : Initialize the library functions | |
3 | |
4 Copyright (c) 2001-2002 Timo Sirainen | |
5 | |
6 Permission is hereby granted, free of charge, to any person obtaining | |
7 a copy of this software and associated documentation files (the | |
8 "Software"), to deal in the Software without restriction, including | |
9 without limitation the rights to use, copy, modify, merge, publish, | |
10 distribute, sublicense, and/or sell copies of the Software, and to | |
11 permit persons to whom the Software is furnished to do so, subject to | |
12 the following conditions: | |
13 | |
14 The above copyright notice and this permission notice shall be | |
15 included in all copies or substantial portions of the Software. | |
16 | |
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
18 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |
20 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | |
21 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | |
22 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | |
23 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
24 */ | |
25 | |
26 #include "lib.h" | |
532
3b53dd1280c6
I/O buffers now use real blocking instead of setting up a sub-ioloop to
Timo Sirainen <tss@iki.fi>
parents:
399
diff
changeset
|
27 #include "alarm-hup.h" |
1314 | 28 #include "hostpid.h" |
0 | 29 |
30 #include <stdlib.h> | |
31 #include <time.h> | |
32 | |
187 | 33 size_t nearest_power(size_t num) |
0 | 34 { |
188
88b31d45c8a4
..and now it uses size_t properly..
Timo Sirainen <tss@iki.fi>
parents:
187
diff
changeset
|
35 size_t n = 1; |
0 | 36 |
192 | 37 i_assert(num <= ((size_t)1 << (BITS_IN_SIZE_T-1))); |
0 | 38 |
39 while (n < num) n <<= 1; | |
40 return n; | |
41 } | |
42 | |
43 void lib_init(void) | |
44 { | |
45 /* standard way to get rand() return different values. */ | |
46 srand((unsigned int) time(NULL)); | |
47 | |
399
383503837741
s/temporary memory pool/data stack/ which is the correct name for it.
Timo Sirainen <tss@iki.fi>
parents:
192
diff
changeset
|
48 data_stack_init(); |
0 | 49 imem_init(); |
1313
c4fa748b9f24
Call the hostpid_init() always at startup. Easier than doing it all around.
Timo Sirainen <tss@iki.fi>
parents:
801
diff
changeset
|
50 hostpid_init(); |
0 | 51 } |
52 | |
53 void lib_deinit(void) | |
54 { | |
532
3b53dd1280c6
I/O buffers now use real blocking instead of setting up a sub-ioloop to
Timo Sirainen <tss@iki.fi>
parents:
399
diff
changeset
|
55 alarm_hup_deinit(); /* doesn't harm even if init is never called */ |
3b53dd1280c6
I/O buffers now use real blocking instead of setting up a sub-ioloop to
Timo Sirainen <tss@iki.fi>
parents:
399
diff
changeset
|
56 |
0 | 57 imem_deinit(); |
399
383503837741
s/temporary memory pool/data stack/ which is the correct name for it.
Timo Sirainen <tss@iki.fi>
parents:
192
diff
changeset
|
58 data_stack_deinit(); |
0 | 59 failures_deinit(); |
60 } |