1147072Sbrooks/*	$OpenBSD: alloc.c,v 1.9 2004/05/04 20:28:40 deraadt Exp $	*/
2147072Sbrooks
3147072Sbrooks/* Memory allocation... */
4147072Sbrooks
5331722Seadler/*
6147072Sbrooks * Copyright (c) 1995, 1996, 1998 The Internet Software Consortium.
7147072Sbrooks * All rights reserved.
8147072Sbrooks *
9147072Sbrooks * Redistribution and use in source and binary forms, with or without
10147072Sbrooks * modification, are permitted provided that the following conditions
11147072Sbrooks * are met:
12147072Sbrooks *
13147072Sbrooks * 1. Redistributions of source code must retain the above copyright
14147072Sbrooks *    notice, this list of conditions and the following disclaimer.
15147072Sbrooks * 2. Redistributions in binary form must reproduce the above copyright
16147072Sbrooks *    notice, this list of conditions and the following disclaimer in the
17147072Sbrooks *    documentation and/or other materials provided with the distribution.
18147072Sbrooks * 3. Neither the name of The Internet Software Consortium nor the names
19147072Sbrooks *    of its contributors may be used to endorse or promote products derived
20147072Sbrooks *    from this software without specific prior written permission.
21147072Sbrooks *
22147072Sbrooks * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
23147072Sbrooks * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24147072Sbrooks * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25147072Sbrooks * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26147072Sbrooks * DISCLAIMED.  IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
27147072Sbrooks * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28147072Sbrooks * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29147072Sbrooks * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30147072Sbrooks * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31147072Sbrooks * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32147072Sbrooks * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33147072Sbrooks * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34147072Sbrooks * SUCH DAMAGE.
35147072Sbrooks *
36147072Sbrooks * This software has been written for the Internet Software Consortium
37147072Sbrooks * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
38147072Sbrooks * Enterprises.  To learn more about the Internet Software Consortium,
39147072Sbrooks * see ``http://www.vix.com/isc''.  To learn more about Vixie
40147072Sbrooks * Enterprises, see ``http://www.vix.com''.
41147072Sbrooks */
42147072Sbrooks
43149399Sbrooks#include <sys/cdefs.h>
44149399Sbrooks__FBSDID("$FreeBSD$");
45149399Sbrooks
46147072Sbrooks#include "dhcpd.h"
47147072Sbrooks
48147072Sbrooksstruct string_list *
49147072Sbrooksnew_string_list(size_t size)
50147072Sbrooks{
51147072Sbrooks	struct string_list *rval;
52147072Sbrooks
53147072Sbrooks	rval = calloc(1, sizeof(struct string_list) + size);
54147072Sbrooks	if (rval != NULL)
55147072Sbrooks		rval->string = ((char *)rval) + sizeof(struct string_list);
56147072Sbrooks	return (rval);
57147072Sbrooks}
58147072Sbrooks
59147072Sbrooksstruct hash_table *
60147072Sbrooksnew_hash_table(int count)
61147072Sbrooks{
62147072Sbrooks	struct hash_table *rval;
63147072Sbrooks
64147072Sbrooks	rval = calloc(1, sizeof(struct hash_table) -
65147072Sbrooks	    (DEFAULT_HASH_SIZE * sizeof(struct hash_bucket *)) +
66147072Sbrooks	    (count * sizeof(struct hash_bucket *)));
67147072Sbrooks	if (rval == NULL)
68147072Sbrooks		return (NULL);
69147072Sbrooks	rval->hash_count = count;
70147072Sbrooks	return (rval);
71147072Sbrooks}
72147072Sbrooks
73147072Sbrooksstruct hash_bucket *
74147072Sbrooksnew_hash_bucket(void)
75147072Sbrooks{
76147072Sbrooks	struct hash_bucket *rval = calloc(1, sizeof(struct hash_bucket));
77147072Sbrooks
78147072Sbrooks	return (rval);
79147072Sbrooks}
80