Browse code

shm init

Bogdan-Andrei Iancu authored on 05/12/2001 17:09:06
Showing 3 changed files
... ...
@@ -463,7 +463,24 @@ int main(int argc, char** argv)
463 463
 				strerror(errno));
464 464
 		goto error;
465 465
 	}
466
-	
466
+
467
+	/*init mallocs (before parsing cfg !)*/
468
+#ifdef PKG_MALLOC
469
+	/*init mem*/
470
+	mem_block=qm_malloc_init(mem_pool, PKG_MEM_POOL_SIZE);
471
+	if (mem_block==0){
472
+		LOG(L_CRIT, "could not initialize memory pool\n");
473
+		goto error;
474
+	}
475
+#endif
476
+
477
+#ifdef SHM_MEM
478
+	if (shm_mem_init()==-1) {
479
+		LOG(L_CRIT, "could not initialize shared memory pool, exiting...\n");
480
+		goto error;
481
+	}
482
+#endif
483
+
467 484
 	yyin=cfg_stream;
468 485
 	if ((yyparse()!=0)||(cfg_errors)){
469 486
 		fprintf(stderr, "ERROR: bad config file (%d errors)\n", cfg_errors);
... ...
@@ -540,22 +557,7 @@ int main(int argc, char** argv)
540 557
 		if ( daemonize(argv[0]) <0 ) goto error;
541 558
 	}
542 559
 
543
-#ifdef PKG_MALLOC
544
-	/*init mem*/
545
-	mem_block=qm_malloc_init(mem_pool, PKG_MEM_POOL_SIZE);
546
-	if (mem_block==0){
547
-		LOG(L_CRIT, "could not initialize memory pool\n");
548
-		goto error;
549
-	}
550
-#endif
551
-	
552
-#ifdef SHM_MEM
553
-	if (shm_mem_init()==-1) {
554
-		LOG(L_CRIT, "could not initialize shared memory pool, exiting...\n");
555
-		goto error;
556
-	}
557
-#endif
558
-	
560
+
559 561
 	return main_loop();
560 562
 
561 563
 
... ...
@@ -88,7 +88,8 @@ struct s_table* init_hash_table()
88 88
    int       i;
89 89
 
90 90
    /*allocs the table*/
91
-   hash_table = sh_malloc(  sizeof( struct s_table ) );
91
+   hash_table = (struct s_table*)sh_malloc(  sizeof( struct s_table ) );
92
+    printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXX\n");
92 93
    if ( !hash_table )
93 94
       goto error;
94 95
 
... ...
@@ -131,7 +132,7 @@ struct cell*  build_cell( struct sip_msg* p_msg )
131 132
       return 0;
132 133
 
133 134
    /* allocs a new cell */
134
-   new_cell = sh_malloc( sizeof( struct cell ) );
135
+   new_cell = (struct cell*)sh_malloc( sizeof( struct cell ) );
135 136
    if  ( !new_cell )
136 137
       return 0;
137 138
 
... ...
@@ -1,6 +1,7 @@
1 1
 #ifndef _SH_MALLOC_H
2 2
 #define _SH_MALLOC_H
3 3
 
4
+#include "../../shm_mem.h"
4 5
 
5 6
 /*
6 7
 #if defined SHM_MEM
... ...
@@ -15,8 +16,8 @@
15 16
 
16 17
 #include <stdlib.h>
17 18
 
18
-#define sh_malloc(size)		malloc((size))
19
-#define sh_free(ptr)		free((ptr))
19
+#define sh_malloc(size)		shm_malloc((size))
20
+#define sh_free(ptr)		shm_free((ptr))
20 21
 
21 22
 #endif
22 23