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. */
63 MTYPE_RIPNG_AGGREGATE
,
67 MTYPE_ACCESS_LIST_STR
,
70 MTYPE_PREFIX_LIST_STR
,
71 MTYPE_PREFIX_LIST_ENTRY
,
74 MTYPE_ROUTE_MAP_INDEX
,
76 MTYPE_ROUTE_MAP_RULE_STR
,
77 MTYPE_ROUTE_MAP_COMPILED
,
93 MTYPE_OSPF_AREA_RANGE
,
95 MTYPE_OSPF_NEIGHBOR_STATIC
,
109 MTYPE_OSPF_CRYPT_KEY
,
110 MTYPE_OSPF_EXTERNAL_INFO
,
114 MTYPE_OSPF_IF_PARAMS
,
119 MTYPE_OSPF6_NEIGHBOR
,
124 MTYPE_OSPF6_LSA_SUMMARY
,
129 MTYPE_OSPF6_EXTERNAL_INFO
,
136 MTYPE_PEER_UPDATE_SOURCE
,
139 MTYPE_BGP_CONFED_LIST
,
140 MTYPE_BGP_NEXTHOP_CACHE
,
142 MTYPE_BGP_DAMP_ARRAY
,
144 MTYPE_BGP_ATTR_QUEUE
,
145 MTYPE_BGP_ROUTE_QUEUE
,
150 MTYPE_BGP_ADVERTISE_ATTR
,
164 MTYPE_ECOMMUNITY_VAL
,
165 MTYPE_ECOMMUNITY_STR
,
167 /* community-list and extcommunity-list. */
168 MTYPE_COMMUNITY_LIST_HANDLER
,
169 MTYPE_COMMUNITY_LIST
,
170 MTYPE_COMMUNITY_LIST_NAME
,
171 MTYPE_COMMUNITY_LIST_ENTRY
,
172 MTYPE_COMMUNITY_LIST_CONFIG
,
177 MTYPE_RIP_OFFSET_LIST
,
184 MTYPE_VTYSH_CONFIG_LINE
,
193 #define XMALLOC(mtype, size) \
194 mtype_zmalloc (__FILE__, __LINE__, (mtype), (size))
195 #define XCALLOC(mtype, size) \
196 mtype_zcalloc (__FILE__, __LINE__, (mtype), (size))
197 #define XREALLOC(mtype, ptr, size) \
198 mtype_zrealloc (__FILE__, __LINE__, (mtype), (ptr), (size))
199 #define XFREE(mtype, ptr) \
200 mtype_zfree (__FILE__, __LINE__, (mtype), (ptr))
201 #define XSTRDUP(mtype, str) \
202 mtype_zstrdup (__FILE__, __LINE__, (mtype), (str))
204 #define XMALLOC(mtype, size) zmalloc ((mtype), (size))
205 #define XCALLOC(mtype, size) zcalloc ((mtype), (size))
206 #define XREALLOC(mtype, ptr, size) zrealloc ((mtype), (ptr), (size))
207 #define XFREE(mtype, ptr) zfree ((mtype), (ptr))
208 #define XSTRDUP(mtype, str) zstrdup ((mtype), (str))
209 #endif /* MEMORY_LOG */
211 /* Prototypes of memory function. */
212 void *zmalloc (int type
, size_t size
);
213 void *zcalloc (int type
, size_t size
);
214 void *zrealloc (int type
, void *ptr
, size_t size
);
215 void zfree (int type
, void *ptr
);
216 char *zstrdup (int type
, char *str
);
218 void *mtype_zmalloc (const char *file
,
223 void *mtype_zcalloc (const char *file
,
229 void *mtype_zrealloc (const char *file
,
235 void mtype_zfree (const char *file
,
240 char *mtype_zstrdup (const char *file
,
246 #endif /* _ZEBRA_MEMORY_H */