Mercurial > dovecot > core-2.2
annotate src/lib/imem.c @ 22664:fea53c2725c0
director: Fix director_max_parallel_moves/kicks type
Should be uint, not time.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Thu, 09 Nov 2017 12:24:16 +0200 |
parents | 2e2563132d5f |
children | cb108f786fb4 |
rev | line source |
---|---|
21390
2e2563132d5f
Updated copyright notices to include the year 2017.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
19552
diff
changeset
|
1 /* Copyright (c) 2002-2017 Dovecot authors, see the included COPYING file */ |
0 | 2 |
3 #include "lib.h" | |
4 | |
5356
48fe4fe9ef64
Added system_clean_pool. default_pool is now set statically, so it can be
Timo Sirainen <tss@iki.fi>
parents:
4633
diff
changeset
|
5 pool_t default_pool = &static_system_pool; |
0 | 6 |
183
4a7ab9e94f25
size_t fixes for lib/. Changed OFF_T_FORMAT to PRIuOFF_T which is more
Timo Sirainen <tss@iki.fi>
parents:
5
diff
changeset
|
7 void *i_malloc(size_t size) |
0 | 8 { |
17638
a5f479be46b9
lib: cosmetic - whitespace cleanup in allocator/memory-related code
Phil Carmody <phil@dovecot.fi>
parents:
17130
diff
changeset
|
9 return p_malloc(default_pool, size); |
0 | 10 } |
11 | |
941
4d6b69558add
Added old_size parameter to p_realloc() - we rarely need it and this way
Timo Sirainen <tss@iki.fi>
parents:
903
diff
changeset
|
12 void *i_realloc(void *mem, size_t old_size, size_t new_size) |
0 | 13 { |
17638
a5f479be46b9
lib: cosmetic - whitespace cleanup in allocator/memory-related code
Phil Carmody <phil@dovecot.fi>
parents:
17130
diff
changeset
|
14 return p_realloc(default_pool, mem, old_size, new_size); |
0 | 15 } |
16 | |
17 char *i_strdup(const char *str) | |
18 { | |
17638
a5f479be46b9
lib: cosmetic - whitespace cleanup in allocator/memory-related code
Phil Carmody <phil@dovecot.fi>
parents:
17130
diff
changeset
|
19 return p_strdup(default_pool, str); |
0 | 20 } |
21 | |
22 char *i_strdup_empty(const char *str) | |
23 { | |
17638
a5f479be46b9
lib: cosmetic - whitespace cleanup in allocator/memory-related code
Phil Carmody <phil@dovecot.fi>
parents:
17130
diff
changeset
|
24 return p_strdup_empty(default_pool, str); |
0 | 25 } |
26 | |
898
0d5be52d7131
Use unsigned char* when accessing non-NUL terminating strings. Compiler
Timo Sirainen <tss@iki.fi>
parents:
839
diff
changeset
|
27 char *i_strdup_until(const void *str, const void *end) |
5
1b34ec11fff8
Message data is parsed in blocks (no longer entirely mmap()ed). Several
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
28 { |
1b34ec11fff8
Message data is parsed in blocks (no longer entirely mmap()ed). Several
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
29 return p_strdup_until(default_pool, str, end); |
1b34ec11fff8
Message data is parsed in blocks (no longer entirely mmap()ed). Several
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
30 } |
1b34ec11fff8
Message data is parsed in blocks (no longer entirely mmap()ed). Several
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
31 |
898
0d5be52d7131
Use unsigned char* when accessing non-NUL terminating strings. Compiler
Timo Sirainen <tss@iki.fi>
parents:
839
diff
changeset
|
32 char *i_strndup(const void *str, size_t max_chars) |
0 | 33 { |
17638
a5f479be46b9
lib: cosmetic - whitespace cleanup in allocator/memory-related code
Phil Carmody <phil@dovecot.fi>
parents:
17130
diff
changeset
|
34 return p_strndup(default_pool, str, max_chars); |
0 | 35 } |
36 | |
37 char *i_strdup_printf(const char *format, ...) | |
38 { | |
39 va_list args; | |
17638
a5f479be46b9
lib: cosmetic - whitespace cleanup in allocator/memory-related code
Phil Carmody <phil@dovecot.fi>
parents:
17130
diff
changeset
|
40 char *ret; |
0 | 41 |
17638
a5f479be46b9
lib: cosmetic - whitespace cleanup in allocator/memory-related code
Phil Carmody <phil@dovecot.fi>
parents:
17130
diff
changeset
|
42 va_start(args, format); |
0 | 43 ret = p_strdup_vprintf(default_pool, format, args); |
44 va_end(args); | |
17638
a5f479be46b9
lib: cosmetic - whitespace cleanup in allocator/memory-related code
Phil Carmody <phil@dovecot.fi>
parents:
17130
diff
changeset
|
45 return ret; |
0 | 46 } |
47 | |
48 char *i_strdup_vprintf(const char *format, va_list args) | |
49 { | |
17638
a5f479be46b9
lib: cosmetic - whitespace cleanup in allocator/memory-related code
Phil Carmody <phil@dovecot.fi>
parents:
17130
diff
changeset
|
50 return p_strdup_vprintf(default_pool, format, args); |
0 | 51 } |
52 | |
53 char *i_strconcat(const char *str1, ...) | |
54 { | |
55 va_list args; | |
56 char *ret; | |
17638
a5f479be46b9
lib: cosmetic - whitespace cleanup in allocator/memory-related code
Phil Carmody <phil@dovecot.fi>
parents:
17130
diff
changeset
|
57 size_t len; |
0 | 58 |
59 va_start(args, str1); | |
60 | |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
61 T_BEGIN { |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
62 const char *temp = vstrconcat(str1, args, &len); |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
63 |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
64 if (temp == NULL) |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
65 ret = NULL; |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
66 else { |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
67 t_buffer_alloc(len); |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
68 ret = p_malloc(default_pool, len); |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
69 memcpy(ret, temp, len); |
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
70 } |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
71 } T_END; |
0 | 72 |
73 va_end(args); | |
17638
a5f479be46b9
lib: cosmetic - whitespace cleanup in allocator/memory-related code
Phil Carmody <phil@dovecot.fi>
parents:
17130
diff
changeset
|
74 return ret; |
0 | 75 } |