Bogdan-Andrei Iancu 24 vuotta sitten
vanhempi
commit
e8e9c7a961
3 muutettua tiedostoa jossa 25 lisäystä ja 21 poistoa
  1. 19 17
      main.c
  2. 3 2
      modules/tm/h_table.c
  3. 3 2
      modules/tm/sh_malloc.h

+ 19 - 17
main.c

@@ -463,7 +463,24 @@ int main(int argc, char** argv)
 				strerror(errno));
 		goto error;
 	}
-	
+
+	/*init mallocs (before parsing cfg !)*/
+#ifdef PKG_MALLOC
+	/*init mem*/
+	mem_block=qm_malloc_init(mem_pool, PKG_MEM_POOL_SIZE);
+	if (mem_block==0){
+		LOG(L_CRIT, "could not initialize memory pool\n");
+		goto error;
+	}
+#endif
+
+#ifdef SHM_MEM
+	if (shm_mem_init()==-1) {
+		LOG(L_CRIT, "could not initialize shared memory pool, exiting...\n");
+		goto error;
+	}
+#endif
+
 	yyin=cfg_stream;
 	if ((yyparse()!=0)||(cfg_errors)){
 		fprintf(stderr, "ERROR: bad config file (%d errors)\n", cfg_errors);
@@ -540,22 +557,7 @@ int main(int argc, char** argv)
 		if ( daemonize(argv[0]) <0 ) goto error;
 	}
 
-#ifdef PKG_MALLOC
-	/*init mem*/
-	mem_block=qm_malloc_init(mem_pool, PKG_MEM_POOL_SIZE);
-	if (mem_block==0){
-		LOG(L_CRIT, "could not initialize memory pool\n");
-		goto error;
-	}
-#endif
-	
-#ifdef SHM_MEM
-	if (shm_mem_init()==-1) {
-		LOG(L_CRIT, "could not initialize shared memory pool, exiting...\n");
-		goto error;
-	}
-#endif
-	
+
 	return main_loop();
 
 

+ 3 - 2
modules/tm/h_table.c

@@ -88,7 +88,8 @@ struct s_table* init_hash_table()
    int       i;
 
    /*allocs the table*/
-   hash_table = sh_malloc(  sizeof( struct s_table ) );
+   hash_table = (struct s_table*)sh_malloc(  sizeof( struct s_table ) );
+    printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXX\n");
    if ( !hash_table )
       goto error;
 
@@ -131,7 +132,7 @@ struct cell*  build_cell( struct sip_msg* p_msg )
       return 0;
 
    /* allocs a new cell */
-   new_cell = sh_malloc( sizeof( struct cell ) );
+   new_cell = (struct cell*)sh_malloc( sizeof( struct cell ) );
    if  ( !new_cell )
       return 0;
 

+ 3 - 2
modules/tm/sh_malloc.h

@@ -1,6 +1,7 @@
 #ifndef _SH_MALLOC_H
 #define _SH_MALLOC_H
 
+#include "../../shm_mem.h"
 
 /*
 #if defined SHM_MEM
@@ -15,8 +16,8 @@
 
 #include <stdlib.h>
 
-#define sh_malloc(size)		malloc((size))
-#define sh_free(ptr)		free((ptr))
+#define sh_malloc(size)		shm_malloc((size))
+#define sh_free(ptr)		shm_free((ptr))
 
 #endif