1 /* Memory management routine
2 Copyright (C) 1998 Kunihiro Ishiguro
4 This file is part of GNU Zebra.
6 GNU Zebra is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 GNU Zebra is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Zebra; see the file COPYING. If not, write to the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 #ifndef _ZEBRA_MEMORY_H
22 #define _ZEBRA_MEMORY_H
24 /* #define MEMORY_LOG */
26 /* For tagging memory, below is the type of the memory. */
62 MTYPE_RIPNG_AGGREGATE,
66 MTYPE_ACCESS_LIST_STR,
69 MTYPE_PREFIX_LIST_STR,
70 MTYPE_PREFIX_LIST_ENTRY,
73 MTYPE_ROUTE_MAP_INDEX,
75 MTYPE_ROUTE_MAP_RULE_STR,
76 MTYPE_ROUTE_MAP_COMPILED,
92 MTYPE_OSPF_AREA_RANGE,
94 MTYPE_OSPF_NEIGHBOR_STATIC,
108 MTYPE_OSPF_CRYPT_KEY,
109 MTYPE_OSPF_EXTERNAL_INFO,
113 MTYPE_OSPF_IF_PARAMS,
118 MTYPE_OSPF6_NEIGHBOR,
123 MTYPE_OSPF6_LSA_SUMMARY,
128 MTYPE_OSPF6_EXTERNAL_INFO,
135 MTYPE_PEER_UPDATE_SOURCE,
138 MTYPE_BGP_CONFED_LIST,
139 MTYPE_BGP_NEXTHOP_CACHE,
141 MTYPE_BGP_DAMP_ARRAY,
143 MTYPE_BGP_ATTR_QUEUE,
144 MTYPE_BGP_ROUTE_QUEUE,
149 MTYPE_BGP_ADVERTISE_ATTR,
163 MTYPE_ECOMMUNITY_VAL,
164 MTYPE_ECOMMUNITY_STR,
166 /* community-list and extcommunity-list. */
167 MTYPE_COMMUNITY_LIST_HANDLER,
168 MTYPE_COMMUNITY_LIST,
169 MTYPE_COMMUNITY_LIST_NAME,
170 MTYPE_COMMUNITY_LIST_ENTRY,
171 MTYPE_COMMUNITY_LIST_CONFIG,
176 MTYPE_RIP_OFFSET_LIST,
183 MTYPE_VTYSH_CONFIG_LINE,
189 #define XMALLOC(mtype, size) \
190 mtype_zmalloc (__FILE__, __LINE__, (mtype), (size))
191 #define XCALLOC(mtype, size) \
192 mtype_zcalloc (__FILE__, __LINE__, (mtype), (size))
193 #define XREALLOC(mtype, ptr, size) \
194 mtype_zrealloc (__FILE__, __LINE__, (mtype), (ptr), (size))
195 #define XFREE(mtype, ptr) \
196 mtype_zfree (__FILE__, __LINE__, (mtype), (ptr))
197 #define XSTRDUP(mtype, str) \
198 mtype_zstrdup (__FILE__, __LINE__, (mtype), (str))
200 #define XMALLOC(mtype, size) zmalloc ((mtype), (size))
201 #define XCALLOC(mtype, size) zcalloc ((mtype), (size))
202 #define XREALLOC(mtype, ptr, size) zrealloc ((mtype), (ptr), (size))
203 #define XFREE(mtype, ptr) zfree ((mtype), (ptr))
204 #define XSTRDUP(mtype, str) zstrdup ((mtype), (str))
205 #endif /* MEMORY_LOG */
207 /* Prototypes of memory function. */
208 void *zmalloc (int type, size_t size);
209 void *zcalloc (int type, size_t size);
210 void *zrealloc (int type, void *ptr, size_t size);
211 void zfree (int type, void *ptr);
212 char *zstrdup (int type, char *str);
214 void *mtype_zmalloc (const char *file,
219 void *mtype_zcalloc (const char *file,
225 void *mtype_zrealloc (const char *file,
231 void mtype_zfree (const char *file,
236 char *mtype_zstrdup (const char *file,
242 #endif /* _ZEBRA_MEMORY_H */