1*c363a9cbScegger /* $NetBSD: zalloc.c,v 1.7 2009/03/18 16:00:21 cegger Exp $ */
2077cae26Ssimonb
3077cae26Ssimonb /*-
4077cae26Ssimonb * Copyright (c) 1999 The NetBSD Foundation, Inc.
5077cae26Ssimonb * All rights reserved.
6077cae26Ssimonb *
7077cae26Ssimonb * This code is derived from software contributed to The NetBSD Foundation
8077cae26Ssimonb * by Simon Burge.
9077cae26Ssimonb *
10077cae26Ssimonb * Redistribution and use in source and binary forms, with or without
11077cae26Ssimonb * modification, are permitted provided that the following conditions
12077cae26Ssimonb * are met:
13077cae26Ssimonb * 1. Redistributions of source code must retain the above copyright
14077cae26Ssimonb * notice, this list of conditions and the following disclaimer.
15077cae26Ssimonb * 2. Redistributions in binary form must reproduce the above copyright
16077cae26Ssimonb * notice, this list of conditions and the following disclaimer in the
17077cae26Ssimonb * documentation and/or other materials provided with the distribution.
18077cae26Ssimonb *
19077cae26Ssimonb * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20077cae26Ssimonb * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21077cae26Ssimonb * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22077cae26Ssimonb * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23077cae26Ssimonb * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24077cae26Ssimonb * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25077cae26Ssimonb * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26077cae26Ssimonb * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27077cae26Ssimonb * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28077cae26Ssimonb * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29077cae26Ssimonb * POSSIBILITY OF SUCH DAMAGE.
30077cae26Ssimonb */
31077cae26Ssimonb
32077cae26Ssimonb
33077cae26Ssimonb #include "zutil.h"
34728d6723Sthorpej #include <lib/libsa/stand.h>
35077cae26Ssimonb
36077cae26Ssimonb /*
37077cae26Ssimonb * A simple implementation of zcalloc and zcfree in terms of the libsa
38077cae26Ssimonb * alloc and free.
39077cae26Ssimonb */
40077cae26Ssimonb
41077cae26Ssimonb voidpf
zcalloc(voidpf opaque,unsigned int items,unsigned int size)42c3a9c74aStsutsui zcalloc(voidpf opaque, unsigned int items, unsigned int size)
43077cae26Ssimonb {
44c3a9c74aStsutsui unsigned int totalsize;
45077cae26Ssimonb
46077cae26Ssimonb totalsize = items * size;
47077cae26Ssimonb opaque = alloc(totalsize);
48077cae26Ssimonb if (opaque != NULL)
49*c363a9cbScegger memset(opaque, 0, totalsize);
50c3a9c74aStsutsui return opaque;
51077cae26Ssimonb }
52077cae26Ssimonb
53077cae26Ssimonb void
zcfree(voidpf opaque,voidpf ptr)54c3a9c74aStsutsui zcfree(voidpf opaque, voidpf ptr)
55077cae26Ssimonb {
56c3a9c74aStsutsui
576645a4f3Schristos dealloc(ptr, 0); /* XXX: size not known */
58077cae26Ssimonb }
59