alloc.c revision 149399
1249261Sdim/*	$OpenBSD: alloc.c,v 1.9 2004/05/04 20:28:40 deraadt Exp $	*/
2249261Sdim
3353358Sdim/* Memory allocation... */
4353358Sdim
5353358Sdim/*
6249261Sdim * Copyright (c) 1995, 1996, 1998 The Internet Software Consortium.
7249261Sdim * All rights reserved.
8249261Sdim *
9249261Sdim * Redistribution and use in source and binary forms, with or without
10249261Sdim * modification, are permitted provided that the following conditions
11249261Sdim * are met:
12249261Sdim *
13249261Sdim * 1. Redistributions of source code must retain the above copyright
14249261Sdim *    notice, this list of conditions and the following disclaimer.
15249261Sdim * 2. Redistributions in binary form must reproduce the above copyright
16249261Sdim *    notice, this list of conditions and the following disclaimer in the
17344779Sdim *    documentation and/or other materials provided with the distribution.
18249261Sdim * 3. Neither the name of The Internet Software Consortium nor the names
19249261Sdim *    of its contributors may be used to endorse or promote products derived
20249261Sdim *    from this software without specific prior written permission.
21249261Sdim *
22249261Sdim * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
23249261Sdim * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24249261Sdim * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25249261Sdim * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26249261Sdim * DISCLAIMED.  IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
27249261Sdim * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28249261Sdim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29249261Sdim * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30296417Sdim * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31276479Sdim * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32276479Sdim * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33276479Sdim * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34249261Sdim * SUCH DAMAGE.
35249261Sdim *
36249261Sdim * This software has been written for the Internet Software Consortium
37249261Sdim * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
38360784Sdim * Enterprises.  To learn more about the Internet Software Consortium,
39360784Sdim * see ``http://www.vix.com/isc''.  To learn more about Vixie
40360784Sdim * Enterprises, see ``http://www.vix.com''.
41360784Sdim */
42360784Sdim
43288943Sdim#include <sys/cdefs.h>
44288943Sdim__FBSDID("$FreeBSD: head/sbin/dhclient/alloc.c 149399 2005-08-23 23:59:55Z brooks $");
45249261Sdim
46249261Sdim#include "dhcpd.h"
47249261Sdim
48341825Sdimstruct string_list *
49341825Sdimnew_string_list(size_t size)
50249261Sdim{
51280031Sdim	struct string_list *rval;
52280031Sdim
53280031Sdim	rval = calloc(1, sizeof(struct string_list) + size);
54280031Sdim	if (rval != NULL)
55280031Sdim		rval->string = ((char *)rval) + sizeof(struct string_list);
56280031Sdim	return (rval);
57280031Sdim}
58341825Sdim
59341825Sdimstruct hash_table *
60341825Sdimnew_hash_table(int count)
61280031Sdim{
62341825Sdim	struct hash_table *rval;
63280031Sdim
64280031Sdim	rval = calloc(1, sizeof(struct hash_table) -
65341825Sdim	    (DEFAULT_HASH_SIZE * sizeof(struct hash_bucket *)) +
66341825Sdim	    (count * sizeof(struct hash_bucket *)));
67249261Sdim	if (rval == NULL)
68341825Sdim		return (NULL);
69341825Sdim	rval->hash_count = count;
70341825Sdim	return (rval);
71341825Sdim}
72341825Sdim
73341825Sdimstruct hash_bucket *
74341825Sdimnew_hash_bucket(void)
75341825Sdim{
76249261Sdim	struct hash_bucket *rval = calloc(1, sizeof(struct hash_bucket));
77341825Sdim
78249261Sdim	return (rval);
79280031Sdim}
80341825Sdim