forked from OpenSIPS/opensips
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmem.h
More file actions
132 lines (120 loc) · 3.99 KB
/
Copy pathmem.h
File metadata and controls
132 lines (120 loc) · 3.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/* $Id$
*
* memory related stuff (malloc & friends)
*
* Copyright (C) 2001-2003 FhG Fokus
*
* This file is part of opensips, a free SIP server.
*
* opensips is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version
*
* opensips is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* History:
* --------
* 2003-03-10 __FUNCTION__ is a gcc-ism, defined it to "" for sun cc
* (andrei)
* 2003-03-07 split init_malloc into init_pkg_mallocs & init_shm_mallocs
* (andrei)
*/
#ifndef mem_h
#define mem_h
#include "../config.h"
#include "../dprint.h"
/* fix debug defines, DBG_F_MALLOC <=> DBG_QM_MALLOC */
#ifdef F_MALLOC
#ifdef DBG_F_MALLOC
#ifndef DBG_QM_MALLOC
#define DBG_QM_MALLOC
#endif
#elif defined(DBG_QM_MALLOC)
#define DBG_F_MALLOC
#endif
#endif
#ifdef PKG_MALLOC
# ifdef VQ_MALLOC
# include "vq_malloc.h"
extern struct vqm_block* mem_block;
# elif defined F_MALLOC
# include "f_malloc.h"
extern struct fm_block* mem_block;
# else
# include "q_malloc.h"
extern struct qm_block* mem_block;
# endif
extern char mem_pool[PKG_MEM_POOL_SIZE];
# ifdef DBG_QM_MALLOC
#ifdef __SUNPRO_C
#define __FUNCTION__ "" /* gcc specific */
#endif
# ifdef VQ_MALLOC
# define pkg_malloc(s) vqm_malloc(mem_block, (s),__FILE__, \
__FUNCTION__, __LINE__)
# define pkg_free(p) vqm_free(mem_block, (p), __FILE__, \
__FUNCTION__, __LINE__)
# warn "no proper realloc implementation, use another mem. alloc"
# elif defined F_MALLOC
# define pkg_malloc(s) fm_malloc(mem_block, (s),__FILE__, \
__FUNCTION__, __LINE__)
# define pkg_free(p) fm_free(mem_block, (p), __FILE__, \
__FUNCTION__, __LINE__)
# define pkg_realloc(p, s) fm_realloc(mem_block, (p), (s),__FILE__, \
__FUNCTION__, __LINE__)
# else
# define pkg_malloc(s) qm_malloc(mem_block, (s),__FILE__, \
__FUNCTION__, __LINE__)
# define pkg_realloc(p, s) qm_realloc(mem_block, (p), (s),__FILE__, \
__FUNCTION__, __LINE__)
# define pkg_free(p) qm_free(mem_block, (p), __FILE__, \
__FUNCTION__, __LINE__)
# endif
# else
# ifdef VQ_MALLOC
# define pkg_malloc(s) vqm_malloc(mem_block, (s))
# define pkg_free(p) vqm_free(mem_block, (p))
# elif defined F_MALLOC
# define pkg_malloc(s) fm_malloc(mem_block, (s))
# define pkg_realloc(p, s) fm_realloc(mem_block, (p), (s))
# define pkg_free(p) fm_free(mem_block, (p))
# else
# define pkg_malloc(s) qm_malloc(mem_block, (s))
# define pkg_realloc(p, s) qm_realloc(mem_block, (p), (s))
# define pkg_free(p) qm_free(mem_block, (p))
# endif
# endif
# ifdef VQ_MALLOC
# define pkg_status() vqm_status(mem_block)
# elif defined F_MALLOC
# define pkg_status() fm_status(mem_block)
# else
# define pkg_status() qm_status(mem_block)
# endif
#elif defined(SHM_MEM) && defined(USE_SHM_MEM)
# include "shm_mem.h"
# define pkg_malloc(s) shm_malloc((s))
# define pkg_free(p) shm_free((p))
# define pkg_status() shm_status()
#else
# include <stdlib.h>
void *sys_malloc(size_t, const char *, const char *, int);
void *sys_realloc(void *, size_t, const char *, const char *, int);
void sys_free(void *, const char *, const char *, int);
# define SYSTEM_MALLOC
# define pkg_malloc(s) sys_malloc((s), __FILE__, __FUNCTION__, __LINE__)
# define pkg_realloc(ptr, s) sys_realloc((ptr), (s), __FILE__, __FUNCTION__, __LINE__)
# define pkg_free(p) sys_free((p), __FILE__, __FUNCTION__, __LINE__)
# define pkg_status()
#endif
int init_pkg_mallocs();
int init_shm_mallocs();
#endif