CVS substitutes introduced
[sip-router] / mem / mem.c
1 /*
2  * $Id: *
3  */
4
5 #include <stdio.h>
6 #include "../config.h"
7 #include "../dprint.h"
8 #include "../globals.h"
9 #include "mem.h"
10
11 #ifdef PKG_MALLOC
12         #ifdef VQ_MALLOC
13                 #include "vq_malloc.h"
14         #else
15                 #include "q_malloc.h"
16         #endif
17 #endif
18
19 #ifdef SHM_MEM
20 #include "shm_mem.h"
21 #endif
22
23 #ifdef PKG_MALLOC
24         char mem_pool[PKG_MEM_POOL_SIZE];
25         #ifdef VQ_MALLOC
26                 struct vqm_block* mem_block;
27         #elif defined F_MALLOC
28                 struct fm_block* mem_block;
29         #else
30                 struct qm_block* mem_block;
31         #endif
32 #endif
33
34 int init_mallocs()
35 {
36 #ifdef PKG_MALLOC
37         /*init mem*/
38         #ifdef VQ_MALLOC
39                 mem_block=vqm_malloc_init(mem_pool, PKG_MEM_POOL_SIZE);
40         #elif F_MALLOC
41                 mem_block=fm_malloc_init(mem_pool, PKG_MEM_POOL_SIZE);
42         #else
43                 mem_block=qm_malloc_init(mem_pool, PKG_MEM_POOL_SIZE);
44         #endif
45         if (mem_block==0){
46                 LOG(L_CRIT, "could not initialize memory pool\n");
47                 fprintf(stderr, "Too much pkg memory demanded: %d\n",
48                         PKG_MEM_POOL_SIZE );
49                 return -1;
50         }
51 #endif
52
53 #ifdef SHM_MEM
54         if (shm_mem_init()<0) {
55                 LOG(L_CRIT, "could not initialize shared memory pool, exiting...\n");
56                  fprintf(stderr, "Too much shared memory demanded: %d\n",
57                         shm_mem_size );
58                 return -1;
59         }
60 #endif
61         return 0;
62
63 }
64
65