annotate src/lib/mempool-datastack.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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 */
404
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
2
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3 #include "lib.h"
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
4 #include "mempool.h"
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
5
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
6
1489
826bed85c807 Added pool_get_name(), for debugging mostly.
Timo Sirainen <tss@iki.fi>
parents: 944
diff changeset
7 static const char *pool_data_stack_get_name(pool_t pool);
903
fd8888f6f037 Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents: 857
diff changeset
8 static void pool_data_stack_ref(pool_t pool);
3878
bf0a03691989 pool_unref(): set the pool pointer to NULL, so if we're trying to unref it
Timo Sirainen <tss@iki.fi>
parents: 3233
diff changeset
9 static void pool_data_stack_unref(pool_t *pool);
903
fd8888f6f037 Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents: 857
diff changeset
10 static void *pool_data_stack_malloc(pool_t pool, size_t size);
fd8888f6f037 Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents: 857
diff changeset
11 static void pool_data_stack_free(pool_t pool, void *mem);
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 static void *pool_data_stack_realloc(pool_t pool, void *mem,
4d6b69558add Added old_size parameter to p_realloc() - we rarely need it and this way
Timo Sirainen <tss@iki.fi>
parents: 903
diff changeset
13 size_t old_size, size_t new_size);
903
fd8888f6f037 Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents: 857
diff changeset
14 static void pool_data_stack_clear(pool_t pool);
3233
6396b4c0a721 Added p_get_max_easy_alloc_size().
Timo Sirainen <tss@iki.fi>
parents: 1782
diff changeset
15 static size_t pool_data_stack_get_max_easy_alloc_size(pool_t pool);
404
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
16
5026
d7e064f77f79 Don't keep the memory pool virtual functions in the pool structure itself,
Timo Sirainen <tss@iki.fi>
parents: 3878
diff changeset
17 static struct pool_vfuncs static_data_stack_pool_vfuncs = {
1489
826bed85c807 Added pool_get_name(), for debugging mostly.
Timo Sirainen <tss@iki.fi>
parents: 944
diff changeset
18 pool_data_stack_get_name,
826bed85c807 Added pool_get_name(), for debugging mostly.
Timo Sirainen <tss@iki.fi>
parents: 944
diff changeset
19
404
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
20 pool_data_stack_ref,
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
21 pool_data_stack_unref,
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
22
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
23 pool_data_stack_malloc,
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
24 pool_data_stack_free,
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
25
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
26 pool_data_stack_realloc,
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
27
944
4f38538aa4a1 Added alloconly_pool field for checking if pool supports free()
Timo Sirainen <tss@iki.fi>
parents: 941
diff changeset
28 pool_data_stack_clear,
5026
d7e064f77f79 Don't keep the memory pool virtual functions in the pool structure itself,
Timo Sirainen <tss@iki.fi>
parents: 3878
diff changeset
29 pool_data_stack_get_max_easy_alloc_size
d7e064f77f79 Don't keep the memory pool virtual functions in the pool structure itself,
Timo Sirainen <tss@iki.fi>
parents: 3878
diff changeset
30 };
944
4f38538aa4a1 Added alloconly_pool field for checking if pool supports free()
Timo Sirainen <tss@iki.fi>
parents: 941
diff changeset
31
5026
d7e064f77f79 Don't keep the memory pool virtual functions in the pool structure itself,
Timo Sirainen <tss@iki.fi>
parents: 3878
diff changeset
32 static const struct pool static_data_stack_pool = {
10410
b757dab45756 Removed MEMBER() macro. Require C99 style struct initializer.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
33 .v = &static_data_stack_pool_vfuncs,
5026
d7e064f77f79 Don't keep the memory pool virtual functions in the pool structure itself,
Timo Sirainen <tss@iki.fi>
parents: 3878
diff changeset
34
10410
b757dab45756 Removed MEMBER() macro. Require C99 style struct initializer.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
35 .alloconly_pool = TRUE,
b757dab45756 Removed MEMBER() macro. Require C99 style struct initializer.
Timo Sirainen <tss@iki.fi>
parents: 8590
diff changeset
36 .datastack_pool = TRUE
404
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
37 };
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
38
1782
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
39 struct datastack_pool {
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
40 struct pool pool;
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
41 int refcount;
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
42
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
43 unsigned int data_stack_frame;
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
44 };
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
45
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
46 pool_t pool_datastack_create(void)
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
47 {
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
48 struct datastack_pool *dpool;
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
49
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
50 dpool = t_new(struct datastack_pool, 1);
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
51 dpool->pool = static_data_stack_pool;
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
52 dpool->refcount = 1;
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
53 dpool->data_stack_frame = data_stack_frame;
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
54 return &dpool->pool;
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
55 }
404
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
56
6411
6a64e64fa3a3 Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents: 5026
diff changeset
57 static const char *pool_data_stack_get_name(pool_t pool ATTR_UNUSED)
1489
826bed85c807 Added pool_get_name(), for debugging mostly.
Timo Sirainen <tss@iki.fi>
parents: 944
diff changeset
58 {
826bed85c807 Added pool_get_name(), for debugging mostly.
Timo Sirainen <tss@iki.fi>
parents: 944
diff changeset
59 return "data stack";
826bed85c807 Added pool_get_name(), for debugging mostly.
Timo Sirainen <tss@iki.fi>
parents: 944
diff changeset
60 }
826bed85c807 Added pool_get_name(), for debugging mostly.
Timo Sirainen <tss@iki.fi>
parents: 944
diff changeset
61
1782
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
62 static void pool_data_stack_ref(pool_t pool)
404
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
63 {
1782
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
64 struct datastack_pool *dpool = (struct datastack_pool *) pool;
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
65
6825
85385079b044 Use likely() and unlikely() macros to make commonly checked error handling
Timo Sirainen <tss@iki.fi>
parents: 6429
diff changeset
66 if (unlikely(dpool->data_stack_frame != data_stack_frame))
1782
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
67 i_panic("pool_data_stack_ref(): stack frame changed");
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
68
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
69 dpool->refcount++;
404
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
70 }
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
71
3878
bf0a03691989 pool_unref(): set the pool pointer to NULL, so if we're trying to unref it
Timo Sirainen <tss@iki.fi>
parents: 3233
diff changeset
72 static void pool_data_stack_unref(pool_t *pool)
404
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
73 {
3878
bf0a03691989 pool_unref(): set the pool pointer to NULL, so if we're trying to unref it
Timo Sirainen <tss@iki.fi>
parents: 3233
diff changeset
74 struct datastack_pool *dpool = (struct datastack_pool *)*pool;
1782
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
75
6825
85385079b044 Use likely() and unlikely() macros to make commonly checked error handling
Timo Sirainen <tss@iki.fi>
parents: 6429
diff changeset
76 if (unlikely(dpool->data_stack_frame != data_stack_frame))
1782
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
77 i_panic("pool_data_stack_unref(): stack frame changed");
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
78
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
79 dpool->refcount--;
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
80 i_assert(dpool->refcount >= 0);
3878
bf0a03691989 pool_unref(): set the pool pointer to NULL, so if we're trying to unref it
Timo Sirainen <tss@iki.fi>
parents: 3233
diff changeset
81
bf0a03691989 pool_unref(): set the pool pointer to NULL, so if we're trying to unref it
Timo Sirainen <tss@iki.fi>
parents: 3233
diff changeset
82 *pool = NULL;
404
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
83 }
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
84
6411
6a64e64fa3a3 Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents: 5026
diff changeset
85 static void *pool_data_stack_malloc(pool_t pool ATTR_UNUSED, size_t size)
404
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
86 {
1782
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
87 struct datastack_pool *dpool = (struct datastack_pool *) pool;
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
88
6825
85385079b044 Use likely() and unlikely() macros to make commonly checked error handling
Timo Sirainen <tss@iki.fi>
parents: 6429
diff changeset
89 if (unlikely(size == 0 || size > SSIZE_T_MAX))
839
34cb1d196d2b String function cleanups. Allocating 0 bytes of memory is treated as error
Timo Sirainen <tss@iki.fi>
parents: 805
diff changeset
90 i_panic("Trying to allocate %"PRIuSIZE_T" bytes", size);
404
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
91
6825
85385079b044 Use likely() and unlikely() macros to make commonly checked error handling
Timo Sirainen <tss@iki.fi>
parents: 6429
diff changeset
92 if (unlikely(dpool->data_stack_frame != data_stack_frame))
1782
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
93 i_panic("pool_data_stack_malloc(): stack frame changed");
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
94
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
95 return t_malloc0(size);
404
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
96 }
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
97
6411
6a64e64fa3a3 Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents: 5026
diff changeset
98 static void pool_data_stack_free(pool_t pool, void *mem ATTR_UNUSED)
404
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
99 {
1782
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
100 struct datastack_pool *dpool = (struct datastack_pool *) pool;
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
101
6825
85385079b044 Use likely() and unlikely() macros to make commonly checked error handling
Timo Sirainen <tss@iki.fi>
parents: 6429
diff changeset
102 if (unlikely(dpool->data_stack_frame != data_stack_frame))
1782
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
103 i_panic("pool_data_stack_free(): stack frame changed");
404
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
104 }
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
105
1782
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
106 static void *pool_data_stack_realloc(pool_t pool, void *mem,
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
107 size_t old_size, size_t new_size)
404
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
108 {
1782
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
109 struct datastack_pool *dpool = (struct datastack_pool *) pool;
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
110 void *new_mem;
4d6b69558add Added old_size parameter to p_realloc() - we rarely need it and this way
Timo Sirainen <tss@iki.fi>
parents: 903
diff changeset
111
805
5ac361acb316 Marked all non-trivial buffer modifications with @UNSAFE tag. Several
Timo Sirainen <tss@iki.fi>
parents: 404
diff changeset
112 /* @UNSAFE */
6825
85385079b044 Use likely() and unlikely() macros to make commonly checked error handling
Timo Sirainen <tss@iki.fi>
parents: 6429
diff changeset
113 if (unlikely(new_size == 0 || new_size > SSIZE_T_MAX))
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
114 i_panic("Trying to allocate %"PRIuSIZE_T" bytes", new_size);
839
34cb1d196d2b String function cleanups. Allocating 0 bytes of memory is treated as error
Timo Sirainen <tss@iki.fi>
parents: 805
diff changeset
115
6825
85385079b044 Use likely() and unlikely() macros to make commonly checked error handling
Timo Sirainen <tss@iki.fi>
parents: 6429
diff changeset
116 if (unlikely(dpool->data_stack_frame != data_stack_frame))
1782
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
117 i_panic("pool_data_stack_realloc(): stack frame changed");
2f3d906d99d8 data_stack_pool split into two: unsafe_data_stack_pool which works like
Timo Sirainen <tss@iki.fi>
parents: 1741
diff changeset
118
404
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
119 if (mem == NULL)
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
120 return pool_data_stack_malloc(pool, new_size);
404
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
121
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
122 if (old_size >= new_size)
404
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
123 return mem;
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
124
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
125 if (!t_try_realloc(mem, new_size)) {
4d6b69558add Added old_size parameter to p_realloc() - we rarely need it and this way
Timo Sirainen <tss@iki.fi>
parents: 903
diff changeset
126 new_mem = t_malloc(new_size);
4d6b69558add Added old_size parameter to p_realloc() - we rarely need it and this way
Timo Sirainen <tss@iki.fi>
parents: 903
diff changeset
127 memcpy(new_mem, mem, old_size);
4d6b69558add Added old_size parameter to p_realloc() - we rarely need it and this way
Timo Sirainen <tss@iki.fi>
parents: 903
diff changeset
128 mem = new_mem;
404
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
129 }
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
130
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
131 memset((char *) mem + old_size, 0, new_size - old_size);
4d6b69558add Added old_size parameter to p_realloc() - we rarely need it and this way
Timo Sirainen <tss@iki.fi>
parents: 903
diff changeset
132 return mem;
404
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
133 }
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
134
6411
6a64e64fa3a3 Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents: 5026
diff changeset
135 static void pool_data_stack_clear(pool_t pool ATTR_UNUSED)
404
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
136 {
f25e575bf1ca Created datastack_mempool which is used by at least a few temporary
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
137 }
3233
6396b4c0a721 Added p_get_max_easy_alloc_size().
Timo Sirainen <tss@iki.fi>
parents: 1782
diff changeset
138
6396b4c0a721 Added p_get_max_easy_alloc_size().
Timo Sirainen <tss@iki.fi>
parents: 1782
diff changeset
139 static size_t
6411
6a64e64fa3a3 Renamed __attr_*__ to ATTR_*. Renamed __attrs_used__ to ATTRS_DEFINED.
Timo Sirainen <tss@iki.fi>
parents: 5026
diff changeset
140 pool_data_stack_get_max_easy_alloc_size(pool_t pool ATTR_UNUSED)
3233
6396b4c0a721 Added p_get_max_easy_alloc_size().
Timo Sirainen <tss@iki.fi>
parents: 1782
diff changeset
141 {
6396b4c0a721 Added p_get_max_easy_alloc_size().
Timo Sirainen <tss@iki.fi>
parents: 1782
diff changeset
142 return t_get_bytes_available();
6396b4c0a721 Added p_get_max_easy_alloc_size().
Timo Sirainen <tss@iki.fi>
parents: 1782
diff changeset
143 }