2 * Memory management routine
3 * Copyright (C) 1998 Kunihiro Ishiguro
5 * This file is part of GNU Zebra.
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23 #ifndef _ZEBRA_MEMORY_H
24 #define _ZEBRA_MEMORY_H
26 /* #define MEMORY_LOG */
28 /* For tagging memory, below is the type of the memory. */
68 MTYPE_RIPNG_AGGREGATE
,
72 MTYPE_ACCESS_LIST_STR
,
75 MTYPE_PREFIX_LIST_STR
,
76 MTYPE_PREFIX_LIST_ENTRY
,
79 MTYPE_ROUTE_MAP_INDEX
,
81 MTYPE_ROUTE_MAP_RULE_STR
,
82 MTYPE_ROUTE_MAP_COMPILED
,
89 MTYPE_OSPF_AREA_RANGE
,
91 MTYPE_OSPF_NEIGHBOR_STATIC
,
105 MTYPE_OSPF_CRYPT_KEY
,
106 MTYPE_OSPF_EXTERNAL_INFO
,
111 MTYPE_OSPF6_NEIGHBOR
,
116 MTYPE_OSPF6_LSA_SUMMARY
,
121 MTYPE_OSPF6_EXTERNAL_INFO
,
128 MTYPE_COMMUNITY_ENTRY
,
129 MTYPE_COMMUNITY_LIST
,
130 MTYPE_COMMUNITY_REGEXP
,
140 MTYPE_BGP_CONFED_LIST
,
141 MTYPE_RIP_OFFSET_LIST
,
152 MTYPE_BGP_NEXTHOP_CACHE
,
154 MTYPE_BGP_DAMP_ARRAY
,
156 MTYPE_BGP_ATTR_QUEUE
,
157 MTYPE_BGP_ROUTE_QUEUE
,
159 MTYPE_OSPF_IF_PARAMS
,
164 #define XMALLOC(mtype, size) \
165 mtype_zmalloc (__FILE__, __LINE__, (mtype), (size))
166 #define XCALLOC(mtype, num, size) \
167 mtype_zcalloc (__FILE__, __LINE__, (mtype), (num), (size))
168 #define XREALLOC(mtype, ptr, size) \
169 mtype_zrealloc (__FILE__, __LINE__, (mtype), (ptr), (size))
170 #define XFREE(mtype, ptr) \
171 mtype_zfree (__FILE__, __LINE__, (mtype), (ptr))
172 #define XSTRDUP(mtype, str) \
173 mtype_zstrdup (__FILE__, __LINE__, (mtype), (str))
175 #define XMALLOC(mtype, size) zmalloc ((mtype), (size))
176 #define XCALLOC(mtype, num, size) zcalloc ((mtype), (num), (size))
177 #define XREALLOC(mtype, ptr, size) zrealloc ((mtype), (ptr), (size))
178 #define XFREE(mtype, ptr) zfree ((mtype), (ptr))
179 #define XSTRDUP(mtype, str) zstrdup ((mtype), (str))
180 #endif /* MEMORY_LOG */
182 /* Prototypes of memory function. */
183 void *zmalloc (int type
, size_t size
);
184 void *zcalloc (int type
, size_t num
, size_t size
);
185 void *zrealloc (int type
, void *ptr
, size_t size
);
186 void zfree (int type
, void *ptr
);
187 char *zstrdup (int type
, char *str
);
189 void *mtype_zmalloc (const char *file
,
194 void *mtype_zcalloc (const char *file
,
200 void *mtype_zrealloc (const char *file
,
206 void mtype_zfree (const char *file
,
211 char *mtype_zstrdup (const char *file
,
217 #endif /* _ZEBRA_MEMORY_H */