Browse code

- more shm cleanups: splited shm_mem_init in shm_getmem & shm_mem_init_mallocs (all this to keep a common mem/* version between ser and aaa_diameter)

Andrei Pelinescu-Onciul authored on 12/03/2003 18:15:42
Showing 2 changed files
... ...
@@ -25,6 +25,12 @@
25 25
  * along with this program; if not, write to the Free Software 
26 26
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27 27
  */
28
+/*
29
+ * History:
30
+ * --------
31
+ *  2003-03-12  splited shm_mem_init in shm_getmem & shm_mem_init_mallocs
32
+ *               (andrei)
33
+ */
28 34
 
29 35
 
30 36
 #ifdef SHM_MEM
... ...
@@ -114,7 +120,9 @@ void* _shm_resize( void* p , unsigned int s)
114 120
 
115 121
 
116 122
 
117
-int shm_mem_init()
123
+
124
+
125
+int shm_getmem()
118 126
 {
119 127
 
120 128
 #ifdef SHM_MMAP
... ...
@@ -159,9 +167,15 @@ int shm_mem_init()
159 167
 		shm_mem_destroy();
160 168
 		return -1;
161 169
 	}
170
+	return 0;
171
+}
172
+
162 173
 
174
+
175
+int shm_mem_init_mallocs(void* mempool, int pool_size)
176
+{
163 177
 	/* init it for malloc*/
164
-	shm_block=shm_malloc_init(shm_mempool, shm_mem_size);
178
+	shm_block=shm_malloc_init(mempool, pool_size);
165 179
 	if (shm_block==0){
166 180
 		LOG(L_CRIT, "ERROR: shm_mem_init: could not initialize shared"
167 181
 				" malloc\n");
... ...
@@ -187,6 +201,15 @@ int shm_mem_init()
187 201
 }
188 202
 
189 203
 
204
+int shm_mem_init()
205
+{
206
+	int ret;
207
+	
208
+	ret=shm_getmem();
209
+	if (ret<0) return ret;
210
+	return shm_mem_init_mallocs(shm_mempool, shm_mem_size);
211
+}
212
+
190 213
 
191 214
 void shm_mem_destroy()
192 215
 {
... ...
@@ -79,7 +79,10 @@
79 79
 	extern gen_lock_t* mem_lock;
80 80
 
81 81
 
82
-int shm_mem_init();
82
+int shm_mem_init(); /* calls shm_getmem & shm_mem_init_mallocs */
83
+int shm_getmem();   /* allocates the memory (mmap or sysv shmap) */
84
+int shm_mem_init_mallocs(void* mempool, int size); /* initialized the mallocs
85
+													  & the lock */
83 86
 void shm_mem_destroy();
84 87
 
85 88