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 114
 
115 115
 
116 116
 
117
-int shm_mem_init()
117
+
118
+
119
+int shm_getmem()
118 120
 {
119 121
 
120 122
 #ifdef SHM_MMAP
... ...
@@ -159,9 +167,15 @@ int shm_mem_init()
159 159
 		shm_mem_destroy();
160 160
 		return -1;
161 161
 	}
162
+	return 0;
163
+}
164
+
162 165
 
166
+
167
+int shm_mem_init_mallocs(void* mempool, int pool_size)
168
+{
163 169
 	/* init it for malloc*/
164
-	shm_block=shm_malloc_init(shm_mempool, shm_mem_size);
170
+	shm_block=shm_malloc_init(mempool, pool_size);
165 171
 	if (shm_block==0){
166 172
 		LOG(L_CRIT, "ERROR: shm_mem_init: could not initialize shared"
167 173
 				" malloc\n");
... ...
@@ -187,6 +201,15 @@ int shm_mem_init()
187 187
 }
188 188
 
189 189
 
190
+int shm_mem_init()
191
+{
192
+	int ret;
193
+	
194
+	ret=shm_getmem();
195
+	if (ret<0) return ret;
196
+	return shm_mem_init_mallocs(shm_mempool, shm_mem_size);
197
+}
198
+
190 199
 
191 200
 void shm_mem_destroy()
192 201
 {
... ...
@@ -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