xref: /netbsd-src/external/bsd/ntp/dist/include/isc/mem.h (revision cdfa2a7ef92791ba9db70a584a1d904730e6fb46)
1*cdfa2a7eSchristos /*	$NetBSD: mem.h,v 1.6 2020/05/25 20:47:20 christos Exp $	*/
2abb0f93cSkardel 
3abb0f93cSkardel /*
4abb0f93cSkardel  * libntp local override of isc/mem.h to stub it out.
5abb0f93cSkardel  *
6abb0f93cSkardel  * include/isc is searched before any of the lib/isc include
7abb0f93cSkardel  * directories and should be used only for replacement NTP headers
8abb0f93cSkardel  * overriding headers of the same name under lib/isc.
9abb0f93cSkardel  *
10abb0f93cSkardel  * NOTE: this assumes the system malloc is thread-safe and does
11abb0f93cSkardel  *	 not use any normal lib/isc locking.
12abb0f93cSkardel  */
13abb0f93cSkardel 
14abb0f93cSkardel /*
15abb0f93cSkardel  * Copyright (C) 2004-2009  Internet Systems Consortium, Inc. ("ISC")
16abb0f93cSkardel  * Copyright (C) 1997-2001  Internet Software Consortium.
17abb0f93cSkardel  *
18abb0f93cSkardel  * Permission to use, copy, modify, and/or distribute this software for any
19abb0f93cSkardel  * purpose with or without fee is hereby granted, provided that the above
20abb0f93cSkardel  * copyright notice and this permission notice appear in all copies.
21abb0f93cSkardel  *
22abb0f93cSkardel  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
23abb0f93cSkardel  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
24abb0f93cSkardel  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
25abb0f93cSkardel  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
26abb0f93cSkardel  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
27abb0f93cSkardel  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
28abb0f93cSkardel  * PERFORMANCE OF THIS SOFTWARE.
29abb0f93cSkardel  */
30abb0f93cSkardel 
31*cdfa2a7eSchristos /* Id: mem.h,v 1.78.120.3 2009/02/11 03:07:01 jinmei Exp  */
32abb0f93cSkardel 
33abb0f93cSkardel #ifndef ISC_MEM_H
34abb0f93cSkardel #define ISC_MEM_H 1
35abb0f93cSkardel 
36abb0f93cSkardel #include <stdio.h>
37abb0f93cSkardel 
38abb0f93cSkardel #include <isc/lang.h>
39abb0f93cSkardel #include <isc/mutex.h>
40abb0f93cSkardel #include <isc/platform.h>
41abb0f93cSkardel #include <isc/types.h>
42abb0f93cSkardel #include <isc/xml.h>
43abb0f93cSkardel 
44abb0f93cSkardel #include <ntp_stdlib.h>
45abb0f93cSkardel 
46abb0f93cSkardel 
47f003fb54Skardel #define ISC_MEM_UNUSED_ARG(a)		((void)(a))
48f003fb54Skardel 
49f003fb54Skardel #define isc_mem_allocate(c, cnt)	isc_mem_get(c, cnt)
50f003fb54Skardel #define isc_mem_get(c, cnt)		\
51f003fb54Skardel 	( ISC_MEM_UNUSED_ARG(c),	emalloc(cnt) )
52f003fb54Skardel 
53f003fb54Skardel #define isc_mem_reallocate(c, mem, cnt)	\
54f003fb54Skardel 	( ISC_MEM_UNUSED_ARG(c),	erealloc((mem), cnt) )
55f003fb54Skardel 
56f003fb54Skardel #define isc_mem_put(c, mem, cnt)	\
57f003fb54Skardel 	( ISC_MEM_UNUSED_ARG(cnt),	isc_mem_free(c, (mem)) )
58f003fb54Skardel 
59f003fb54Skardel #define isc_mem_free(c, mem)		\
60f003fb54Skardel 	( ISC_MEM_UNUSED_ARG(c),	free(mem) )
61f003fb54Skardel 
62f003fb54Skardel #define isc_mem_strdup(c, str)		\
63f003fb54Skardel 	( ISC_MEM_UNUSED_ARG(c),	estrdup(str) )
64f003fb54Skardel 
658585484eSchristos #define isc__mem_attach(src, ptgt)	do { *(ptgt) = (src); } while (0)
668585484eSchristos #define isc__mem_detach(c)		ISC_MEM_UNUSED_ARG(c)
678585484eSchristos #define isc__mem_printallactive(s)	fprintf((s), \
68f003fb54Skardel 					"isc_mem_printallactive() stubbed.\n")
69abb0f93cSkardel 
70abb0f93cSkardel #endif /* ISC_MEM_H */
71