attached patch removes the VQ_MALLOC memory manager from the
sip-router core. As discussed some time ago, this memory manager
doesn't provide a realloc implementation, and is thus not really
usable for the modules, as some of them needs this. We removed
this in kamailio in the last year, so far nobody missed it.
Signed-off-by: Andrei Pelinescu-Onciul <andrei@iptel.org>
1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,154 +0,0 @@ |
1 |
-/* $Id$ |
|
2 |
- * |
|
3 |
- * |
|
4 |
- * Copyright (C) 2001-2003 FhG Fokus |
|
5 |
- * |
|
6 |
- * This file is part of ser, a free SIP server. |
|
7 |
- * |
|
8 |
- * ser is free software; you can redistribute it and/or modify |
|
9 |
- * it under the terms of the GNU General Public License as published by |
|
10 |
- * the Free Software Foundation; either version 2 of the License, or |
|
11 |
- * (at your option) any later version |
|
12 |
- * |
|
13 |
- * For a license to use the ser software under conditions |
|
14 |
- * other than those described here, or to purchase support for this |
|
15 |
- * software, please contact iptel.org by e-mail at the following addresses: |
|
16 |
- * info@iptel.org |
|
17 |
- * |
|
18 |
- * ser is distributed in the hope that it will be useful, |
|
19 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21 |
- * GNU General Public License for more details. |
|
22 |
- * |
|
23 |
- * You should have received a copy of the GNU General Public License |
|
24 |
- * along with this program; if not, write to the Free Software |
|
25 |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
26 |
- */ |
|
27 |
- |
|
28 |
- |
|
29 |
-#if !defined(VQ_MALLOC_H) && defined(VQ_MALLOC) |
|
30 |
-#define VQ_MALLOC_H |
|
31 |
- |
|
32 |
-#include "../config.h" |
|
33 |
- |
|
34 |
- |
|
35 |
-/* indicates this fragment is not in use (must not be offset of valid |
|
36 |
- aligned fragment beginning |
|
37 |
-*/ |
|
38 |
-#define FR_USED 0xef |
|
39 |
- |
|
40 |
-/*useful macros*/ |
|
41 |
-#define FRAG_END(f) \ |
|
42 |
- ((struct vqm_frag_end*)((char*)(f)-sizeof(struct vqm_frag_end)+ \ |
|
43 |
- (f)->size)) |
|
44 |
- |
|
45 |
-#define FRAG_NEXT(f) \ |
|
46 |
- ((struct vqm_frag*)((char*)(f)+(f)->size)) |
|
47 |
- |
|
48 |
-#define PREV_FRAG_END(f) \ |
|
49 |
- ((struct vqm_frag_end*)((char*)(f)-sizeof(struct vqm_frag_end))) |
|
50 |
- |
|
51 |
-#define FRAG_PREV(f) \ |
|
52 |
- ( (struct vqm_frag*) ( (char*)(f) - PREV_FRAG_END(f)->size )) |
|
53 |
- |
|
54 |
-#define FRAG_ISUSED(f) \ |
|
55 |
- ((f)->u.inuse.magic==FR_USED) |
|
56 |
- |
|
57 |
-/* just a bumper for the step function */ |
|
58 |
-#define EO_STEP -1 |
|
59 |
- |
|
60 |
- |
|
61 |
-#ifdef DBG_QM_MALLOC |
|
62 |
-# define ST_CHECK_PATTERN 0xf0f0f0f0 |
|
63 |
-# define END_CHECK_PATTERN "sExP" |
|
64 |
-# define END_CHECK_PATTERN_LEN 4 |
|
65 |
-# define VQM_OVERHEAD (sizeof(struct vqm_frag)+ \ |
|
66 |
- sizeof(struct vqm_frag_end)+END_CHECK_PATTERN_LEN) |
|
67 |
-# define VQM_DEBUG_FRAG(qm, f) vqm_debug_frag( (qm), (f)) |
|
68 |
-#else |
|
69 |
-# define VQM_DEBUG_FRAG(qm, f) |
|
70 |
-# define VQM_OVERHEAD (sizeof(struct vqm_frag)+ sizeof(struct vqm_frag_end)) |
|
71 |
-#endif |
|
72 |
- |
|
73 |
- |
|
74 |
- |
|
75 |
-struct vqm_frag { |
|
76 |
- /* XXX */ |
|
77 |
- /* total chunk size including all overhead/bellowfoot/roundings/etc */ |
|
78 |
- /* useless as otherwise size implied by bucket (if I really want to save |
|
79 |
- bytes, I'll remove it from here */ |
|
80 |
- unsigned long size; |
|
81 |
- union{ |
|
82 |
- /* pointer to next chunk in a bucket if free */ |
|
83 |
- struct vqm_frag* nxt_free; |
|
84 |
- struct { /* or bucket number if busy */ |
|
85 |
- unsigned char magic; |
|
86 |
- unsigned char bucket; |
|
87 |
- } inuse; |
|
88 |
- } u; |
|
89 |
-#ifdef DBG_QM_MALLOC |
|
90 |
- /* source code info */ |
|
91 |
- char* file; |
|
92 |
- char* func; |
|
93 |
- unsigned long line; |
|
94 |
- /* your safety is important to us! safety signatures */ |
|
95 |
- unsigned long check; |
|
96 |
- char *end_check; |
|
97 |
- /* the size user was originally asking for */ |
|
98 |
- unsigned long demanded_size; |
|
99 |
-#endif |
|
100 |
-}; |
|
101 |
- |
|
102 |
-struct vqm_frag_end{ |
|
103 |
- /* total chunk size including all overhead/bellowfoot/roundings/etc */ |
|
104 |
- unsigned long size; |
|
105 |
- /* XXX */ |
|
106 |
- /* used only for variable-size chunks; might have different |
|
107 |
- data structures for variable/fixed length chunks */ |
|
108 |
- struct vqm_frag* prv_free; |
|
109 |
-}; |
|
110 |
- |
|
111 |
- |
|
112 |
-struct vqm_block{ |
|
113 |
- /* size to bucket table */ |
|
114 |
- unsigned char s2b[ MAX_FIXED_BLOCK ]; |
|
115 |
- /* size to rounded size */ |
|
116 |
- unsigned short s2s[ MAX_FIXED_BLOCK ]; |
|
117 |
- unsigned char max_small_bucket; |
|
118 |
- |
|
119 |
- /* core gained on init ... */ |
|
120 |
- char *core, *init_core, *core_end; |
|
121 |
- /* ... and its available net amount; note that there's lot of |
|
122 |
- free memory in buckets too -- this just tells about memory |
|
123 |
- which has not been assigned to chunks */ |
|
124 |
- unsigned long free_core; |
|
125 |
- /* we allocate huge chunks from the end on; this is the |
|
126 |
- pointer to big chunks |
|
127 |
- */ |
|
128 |
- char *big_chunks; |
|
129 |
- |
|
130 |
- struct vqm_frag* next_free[ MAX_BUCKET +1]; |
|
131 |
-#ifdef DBG_QM_MALLOC |
|
132 |
- unsigned long usage[ MAX_BUCKET +1]; |
|
133 |
-#endif |
|
134 |
-}; |
|
135 |
- |
|
136 |
- |
|
137 |
- |
|
138 |
-struct vqm_block* vqm_malloc_init(char* address, unsigned int size); |
|
139 |
- |
|
140 |
-#ifdef DBG_QM_MALLOC |
|
141 |
-void vqm_debug_frag(struct vqm_block* qm, struct vqm_frag* f); |
|
142 |
-void* vqm_malloc(struct vqm_block*, unsigned int size, char* file, char* func, |
|
143 |
- unsigned int line); |
|
144 |
-void vqm_free(struct vqm_block*, void* p, char* file, char* func, |
|
145 |
- unsigned int line); |
|
146 |
-#else |
|
147 |
-void* vqm_malloc(struct vqm_block*, unsigned int size); |
|
148 |
-void vqm_free(struct vqm_block*, void* p); |
|
149 |
-#endif |
|
150 |
- |
|
151 |
-void vqm_status(struct vqm_block*); |
|
152 |
- |
|
153 |
- |
|
154 |
-#endif |
... | ... |
@@ -77,7 +77,7 @@ struct vqm_frag { |
77 | 77 |
/* total chunk size including all overhead/bellowfoot/roundings/etc */ |
78 | 78 |
/* useless as otherwise size implied by bucket (if I really want to save |
79 | 79 |
bytes, I'll remove it from here */ |
80 |
- unsigned int size; |
|
80 |
+ unsigned long size; |
|
81 | 81 |
union{ |
82 | 82 |
/* pointer to next chunk in a bucket if free */ |
83 | 83 |
struct vqm_frag* nxt_free; |
... | ... |
@@ -90,18 +90,18 @@ struct vqm_frag { |
90 | 90 |
/* source code info */ |
91 | 91 |
char* file; |
92 | 92 |
char* func; |
93 |
- unsigned int line; |
|
93 |
+ unsigned long line; |
|
94 | 94 |
/* your safety is important to us! safety signatures */ |
95 |
- unsigned int check; |
|
95 |
+ unsigned long check; |
|
96 | 96 |
char *end_check; |
97 | 97 |
/* the size user was originally asking for */ |
98 |
- unsigned int demanded_size; |
|
98 |
+ unsigned long demanded_size; |
|
99 | 99 |
#endif |
100 | 100 |
}; |
101 | 101 |
|
102 | 102 |
struct vqm_frag_end{ |
103 | 103 |
/* total chunk size including all overhead/bellowfoot/roundings/etc */ |
104 |
- unsigned int size; |
|
104 |
+ unsigned long size; |
|
105 | 105 |
/* XXX */ |
106 | 106 |
/* used only for variable-size chunks; might have different |
107 | 107 |
data structures for variable/fixed length chunks */ |
... | ... |
@@ -121,7 +121,7 @@ struct vqm_block{ |
121 | 121 |
/* ... and its available net amount; note that there's lot of |
122 | 122 |
free memory in buckets too -- this just tells about memory |
123 | 123 |
which has not been assigned to chunks */ |
124 |
- unsigned int free_core; |
|
124 |
+ unsigned long free_core; |
|
125 | 125 |
/* we allocate huge chunks from the end on; this is the |
126 | 126 |
pointer to big chunks |
127 | 127 |
*/ |
... | ... |
@@ -62,7 +62,8 @@ |
62 | 62 |
# define ST_CHECK_PATTERN 0xf0f0f0f0 |
63 | 63 |
# define END_CHECK_PATTERN "sExP" |
64 | 64 |
# define END_CHECK_PATTERN_LEN 4 |
65 |
-# define VQM_OVERHEAD (sizeof(struct vqm_frag)+ sizeof(struct vqm_frag_end)+END_CHECK_PATTERN_LEN) |
|
65 |
+# define VQM_OVERHEAD (sizeof(struct vqm_frag)+ \ |
|
66 |
+ sizeof(struct vqm_frag_end)+END_CHECK_PATTERN_LEN) |
|
66 | 67 |
# define VQM_DEBUG_FRAG(qm, f) vqm_debug_frag( (qm), (f)) |
67 | 68 |
#else |
68 | 69 |
# define VQM_DEBUG_FRAG(qm, f) |
... | ... |
@@ -1,7 +1,31 @@ |
1 | 1 |
/* $Id$ |
2 | 2 |
* |
3 |
+ * |
|
4 |
+ * Copyright (C) 2001-2003 Fhg Fokus |
|
5 |
+ * |
|
6 |
+ * This file is part of ser, a free SIP server. |
|
7 |
+ * |
|
8 |
+ * ser is free software; you can redistribute it and/or modify |
|
9 |
+ * it under the terms of the GNU General Public License as published by |
|
10 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
11 |
+ * (at your option) any later version |
|
12 |
+ * |
|
13 |
+ * For a license to use the ser software under conditions |
|
14 |
+ * other than those described here, or to purchase support for this |
|
15 |
+ * software, please contact iptel.org by e-mail at the following addresses: |
|
16 |
+ * info@iptel.org |
|
17 |
+ * |
|
18 |
+ * ser is distributed in the hope that it will be useful, |
|
19 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21 |
+ * GNU General Public License for more details. |
|
22 |
+ * |
|
23 |
+ * You should have received a copy of the GNU General Public License |
|
24 |
+ * along with this program; if not, write to the Free Software |
|
25 |
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
3 | 26 |
*/ |
4 | 27 |
|
28 |
+ |
|
5 | 29 |
#if !defined(VQ_MALLOC_H) && defined(VQ_MALLOC) |
6 | 30 |
#define VQ_MALLOC_H |
7 | 31 |
|
... | ... |
@@ -113,6 +113,7 @@ struct vqm_block{ |
113 | 113 |
struct vqm_block* vqm_malloc_init(char* address, unsigned int size); |
114 | 114 |
|
115 | 115 |
#ifdef DBG_QM_MALLOC |
116 |
+void vqm_debug_frag(struct vqm_block* qm, struct vqm_frag* f); |
|
116 | 117 |
void* vqm_malloc(struct vqm_block*, unsigned int size, char* file, char* func, |
117 | 118 |
unsigned int line); |
118 | 119 |
void vqm_free(struct vqm_block*, void* p, char* file, char* func, |
... | ... |
@@ -35,16 +35,18 @@ |
35 | 35 |
|
36 | 36 |
|
37 | 37 |
#ifdef DBG_QM_MALLOC |
38 |
-#define ST_CHECK_PATTERN 0xf0f0f0f0 |
|
39 |
-#define END_CHECK_PATTERN "sExP" |
|
40 |
-#define END_CHECK_PATTERN_LEN 4 |
|
41 |
- |
|
42 |
-#define VQM_DEBUG_FRAG(qm, f) vqm_debug_frag( (qm), (f)) |
|
38 |
+# define ST_CHECK_PATTERN 0xf0f0f0f0 |
|
39 |
+# define END_CHECK_PATTERN "sExP" |
|
40 |
+# define END_CHECK_PATTERN_LEN 4 |
|
41 |
+# define VQM_OVERHEAD (sizeof(struct vqm_frag)+ sizeof(struct vqm_frag_end)+END_CHECK_PATTERN_LEN) |
|
42 |
+# define VQM_DEBUG_FRAG(qm, f) vqm_debug_frag( (qm), (f)) |
|
43 | 43 |
#else |
44 |
-#define VQM_DEBUG_FRAG(qm, f) |
|
44 |
+# define VQM_DEBUG_FRAG(qm, f) |
|
45 |
+# define VQM_OVERHEAD (sizeof(struct vqm_frag)+ sizeof(struct vqm_frag_end)) |
|
45 | 46 |
#endif |
46 | 47 |
|
47 | 48 |
|
49 |
+ |
|
48 | 50 |
struct vqm_frag { |
49 | 51 |
/* XXX */ |
50 | 52 |
/* total chunk size including all overhead/bellowfoot/roundings/etc */ |
... | ... |
@@ -113,14 +115,10 @@ struct vqm_block* vqm_malloc_init(char* address, unsigned int size); |
113 | 115 |
#ifdef DBG_QM_MALLOC |
114 | 116 |
void* vqm_malloc(struct vqm_block*, unsigned int size, char* file, char* func, |
115 | 117 |
unsigned int line); |
116 |
-#else |
|
117 |
-void* vqm_malloc(struct vqm_block*, unsigned int size); |
|
118 |
-#endif |
|
119 |
- |
|
120 |
-#ifdef DBG_QM_MALLOC |
|
121 | 118 |
void vqm_free(struct vqm_block*, void* p, char* file, char* func, |
122 | 119 |
unsigned int line); |
123 | 120 |
#else |
121 |
+void* vqm_malloc(struct vqm_block*, unsigned int size); |
|
124 | 122 |
void vqm_free(struct vqm_block*, void* p); |
125 | 123 |
#endif |
126 | 124 |
|
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,130 @@ |
1 |
+/* $Id$ |
|
2 |
+ * |
|
3 |
+ */ |
|
4 |
+ |
|
5 |
+#if !defined(VQ_MALLOC_H) && defined(VQ_MALLOC) |
|
6 |
+#define VQ_MALLOC_H |
|
7 |
+ |
|
8 |
+#include "../config.h" |
|
9 |
+ |
|
10 |
+ |
|
11 |
+/* indicates this fragment is not in use (must not be offset of valid |
|
12 |
+ aligned fragment beginning |
|
13 |
+*/ |
|
14 |
+#define FR_USED 0xef |
|
15 |
+ |
|
16 |
+/*useful macros*/ |
|
17 |
+#define FRAG_END(f) \ |
|
18 |
+ ((struct vqm_frag_end*)((char*)(f)-sizeof(struct vqm_frag_end)+ \ |
|
19 |
+ (f)->size)) |
|
20 |
+ |
|
21 |
+#define FRAG_NEXT(f) \ |
|
22 |
+ ((struct vqm_frag*)((char*)(f)+(f)->size)) |
|
23 |
+ |
|
24 |
+#define PREV_FRAG_END(f) \ |
|
25 |
+ ((struct vqm_frag_end*)((char*)(f)-sizeof(struct vqm_frag_end))) |
|
26 |
+ |
|
27 |
+#define FRAG_PREV(f) \ |
|
28 |
+ ( (struct vqm_frag*) ( (char*)(f) - PREV_FRAG_END(f)->size )) |
|
29 |
+ |
|
30 |
+#define FRAG_ISUSED(f) \ |
|
31 |
+ ((f)->u.inuse.magic==FR_USED) |
|
32 |
+ |
|
33 |
+/* just a bumper for the step function */ |
|
34 |
+#define EO_STEP -1 |
|
35 |
+ |
|
36 |
+ |
|
37 |
+#ifdef DBG_QM_MALLOC |
|
38 |
+#define ST_CHECK_PATTERN 0xf0f0f0f0 |
|
39 |
+#define END_CHECK_PATTERN "sExP" |
|
40 |
+#define END_CHECK_PATTERN_LEN 4 |
|
41 |
+ |
|
42 |
+#define VQM_DEBUG_FRAG(qm, f) vqm_debug_frag( (qm), (f)) |
|
43 |
+#else |
|
44 |
+#define VQM_DEBUG_FRAG(qm, f) |
|
45 |
+#endif |
|
46 |
+ |
|
47 |
+ |
|
48 |
+struct vqm_frag { |
|
49 |
+ /* XXX */ |
|
50 |
+ /* total chunk size including all overhead/bellowfoot/roundings/etc */ |
|
51 |
+ /* useless as otherwise size implied by bucket (if I really want to save |
|
52 |
+ bytes, I'll remove it from here */ |
|
53 |
+ unsigned int size; |
|
54 |
+ union{ |
|
55 |
+ /* pointer to next chunk in a bucket if free */ |
|
56 |
+ struct vqm_frag* nxt_free; |
|
57 |
+ struct { /* or bucket number if busy */ |
|
58 |
+ unsigned char magic; |
|
59 |
+ unsigned char bucket; |
|
60 |
+ } inuse; |
|
61 |
+ } u; |
|
62 |
+#ifdef DBG_QM_MALLOC |
|
63 |
+ /* source code info */ |
|
64 |
+ char* file; |
|
65 |
+ char* func; |
|
66 |
+ unsigned int line; |
|
67 |
+ /* your safety is important to us! safety signatures */ |
|
68 |
+ unsigned int check; |
|
69 |
+ char *end_check; |
|
70 |
+ /* the size user was originally asking for */ |
|
71 |
+ unsigned int demanded_size; |
|
72 |
+#endif |
|
73 |
+}; |
|
74 |
+ |
|
75 |
+struct vqm_frag_end{ |
|
76 |
+ /* total chunk size including all overhead/bellowfoot/roundings/etc */ |
|
77 |
+ unsigned int size; |
|
78 |
+ /* XXX */ |
|
79 |
+ /* used only for variable-size chunks; might have different |
|
80 |
+ data structures for variable/fixed length chunks */ |
|
81 |
+ struct vqm_frag* prv_free; |
|
82 |
+}; |
|
83 |
+ |
|
84 |
+ |
|
85 |
+struct vqm_block{ |
|
86 |
+ /* size to bucket table */ |
|
87 |
+ unsigned char s2b[ MAX_FIXED_BLOCK ]; |
|
88 |
+ /* size to rounded size */ |
|
89 |
+ unsigned short s2s[ MAX_FIXED_BLOCK ]; |
|
90 |
+ unsigned char max_small_bucket; |
|
91 |
+ |
|
92 |
+ /* core gained on init ... */ |
|
93 |
+ char *core, *init_core, *core_end; |
|
94 |
+ /* ... and its available net amount; note that there's lot of |
|
95 |
+ free memory in buckets too -- this just tells about memory |
|
96 |
+ which has not been assigned to chunks */ |
|
97 |
+ unsigned int free_core; |
|
98 |
+ /* we allocate huge chunks from the end on; this is the |
|
99 |
+ pointer to big chunks |
|
100 |
+ */ |
|
101 |
+ char *big_chunks; |
|
102 |
+ |
|
103 |
+ struct vqm_frag* next_free[ MAX_BUCKET +1]; |
|
104 |
+#ifdef DBG_QM_MALLOC |
|
105 |
+ unsigned long usage[ MAX_BUCKET +1]; |
|
106 |
+#endif |
|
107 |
+}; |
|
108 |
+ |
|
109 |
+ |
|
110 |
+ |
|
111 |
+struct vqm_block* vqm_malloc_init(char* address, unsigned int size); |
|
112 |
+ |
|
113 |
+#ifdef DBG_QM_MALLOC |
|
114 |
+void* vqm_malloc(struct vqm_block*, unsigned int size, char* file, char* func, |
|
115 |
+ unsigned int line); |
|
116 |
+#else |
|
117 |
+void* vqm_malloc(struct vqm_block*, unsigned int size); |
|
118 |
+#endif |
|
119 |
+ |
|
120 |
+#ifdef DBG_QM_MALLOC |
|
121 |
+void vqm_free(struct vqm_block*, void* p, char* file, char* func, |
|
122 |
+ unsigned int line); |
|
123 |
+#else |
|
124 |
+void vqm_free(struct vqm_block*, void* p); |
|
125 |
+#endif |
|
126 |
+ |
|
127 |
+void vqm_status(struct vqm_block*); |
|
128 |
+ |
|
129 |
+ |
|
130 |
+#endif |