2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright 2017 Jason King
16 #include <sys/debug.h>
19 #include <demangle-sys.h>
20 #include "demangle_int.h"
23 zalloc(sysdem_ops_t
*ops
, size_t len
)
25 void *p
= ops
->alloc(len
);
28 (void) memset(p
, 0, len
);
32 * In normal operation, we should never exhaust memory. Either
33 * something's wrong, or the system is so hosed that aborting
34 * shouldn't hurt anything, and it gives us a more useful stack
45 xfree(sysdem_ops_t
*ops
, void *p
, size_t len
)
47 if (p
== NULL
|| len
== 0)
54 xrealloc(sysdem_ops_t
*ops
, void *p
, size_t oldsz
, size_t newsz
)
59 VERIFY3U(newsz
, >, oldsz
);
61 void *temp
= zalloc(ops
, newsz
);
67 (void) memcpy(temp
, p
, oldsz
);
76 def_free(void *p
, size_t len
)
81 static sysdem_ops_t i_sysdem_ops_default
= {
85 sysdem_ops_t
*sysdem_ops_default
= &i_sysdem_ops_default
;