xref: /netbsd-src/sys/arch/hpc/stand/libz/zalloc.c (revision 454af1c0e885cbba6b59706391f770d646303f8c)
1*454af1c0Sdsl /* $NetBSD: zalloc.c,v 1.2 2009/03/14 15:36:06 dsl Exp $ */
2c498580cSuwe 
3c498580cSuwe /*
4c498580cSuwe  * Copyright (c) 2006 Valeriy E. Ushakov
5c498580cSuwe  * All rights reserved.
6c498580cSuwe  *
7c498580cSuwe  * Redistribution and use in source and binary forms, with or without
8c498580cSuwe  * modification, are permitted provided that the following conditions
9c498580cSuwe  * are met:
10c498580cSuwe  * 1. Redistributions of source code must retain the above copyright
11c498580cSuwe  *    notice, this list of conditions and the following disclaimer.
12c498580cSuwe  * 2. Redistributions in binary form must reproduce the above copyright
13c498580cSuwe  *    notice, this list of conditions and the following disclaimer in the
14c498580cSuwe  *    documentation and/or other materials provided with the distribution.
15c498580cSuwe  * 3. The name of the author may not be used to endorse or promote products
16c498580cSuwe  *    derived from this software without specific prior written permission
17c498580cSuwe  *
18c498580cSuwe  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19c498580cSuwe  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20c498580cSuwe  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21c498580cSuwe  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22c498580cSuwe  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23c498580cSuwe  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24c498580cSuwe  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25c498580cSuwe  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26c498580cSuwe  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27c498580cSuwe  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28c498580cSuwe  */
29c498580cSuwe 
30c498580cSuwe #include "zutil.h"
31c498580cSuwe #include <malloc.h>
32c498580cSuwe #include <memory.h>
33c498580cSuwe 
34c498580cSuwe voidpf
zcalloc(voidpf opaque,unsigned items,unsigned size)35*454af1c0Sdsl zcalloc(voidpf opaque, unsigned items, unsigned size)
36c498580cSuwe {
37c498580cSuwe 	size_t total = items * size;
38c498580cSuwe 
39c498580cSuwe 	opaque = malloc(total);
40c498580cSuwe 	if (opaque != NULL)
41c498580cSuwe 		memset(opaque, 0, total);
42c498580cSuwe 	return opaque;
43c498580cSuwe }
44c498580cSuwe 
45c498580cSuwe void
zcfree(voidpf opaque,voidpf ptr)46*454af1c0Sdsl zcfree(voidpf opaque, voidpf ptr)
47c498580cSuwe {
48c498580cSuwe 	free(ptr);
49c498580cSuwe }
50