Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenalloc.c
Go to the documentation of this file.
00001 /* $OpenBSD: alloc.c,v 1.9 2004/05/04 20:28:40 deraadt Exp $ */ 00002 00003 /* Memory allocation... */ 00004 00005 /* 00006 * Copyright (c) 1995, 1996, 1998 The Internet Software Consortium. 00007 * All rights reserved. 00008 * 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions 00011 * are met: 00012 * 00013 * 1. Redistributions of source code must retain the above copyright 00014 * notice, this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright 00016 * notice, this list of conditions and the following disclaimer in the 00017 * documentation and/or other materials provided with the distribution. 00018 * 3. Neither the name of The Internet Software Consortium nor the names 00019 * of its contributors may be used to endorse or promote products derived 00020 * from this software without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND 00023 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 00024 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00025 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00026 * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR 00027 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00028 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00029 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 00030 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00031 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00032 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00033 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00034 * SUCH DAMAGE. 00035 * 00036 * This software has been written for the Internet Software Consortium 00037 * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie 00038 * Enterprises. To learn more about the Internet Software Consortium, 00039 * see ``http://www.vix.com/isc''. To learn more about Vixie 00040 * Enterprises, see ``http://www.vix.com''. 00041 */ 00042 00043 #include "rosdhcp.h" 00044 00045 struct string_list * 00046 new_string_list(size_t size) 00047 { 00048 struct string_list *rval; 00049 00050 rval = calloc(1, sizeof(struct string_list) + size); 00051 if (rval != NULL) 00052 rval->string = ((char *)rval) + sizeof(struct string_list); 00053 return (rval); 00054 } 00055 00056 struct hash_table * 00057 new_hash_table(int count) 00058 { 00059 struct hash_table *rval; 00060 00061 rval = calloc(1, sizeof(struct hash_table) - 00062 (DEFAULT_HASH_SIZE * sizeof(struct hash_bucket *)) + 00063 (count * sizeof(struct hash_bucket *))); 00064 if (rval == NULL) 00065 return (NULL); 00066 rval->hash_count = count; 00067 return (rval); 00068 } 00069 00070 struct hash_bucket * 00071 new_hash_bucket(void) 00072 { 00073 struct hash_bucket *rval = calloc(1, sizeof(struct hash_bucket)); 00074 00075 return (rval); 00076 } 00077 00078 void 00079 dfree(void *ptr, char *name) 00080 { 00081 if (!ptr) { 00082 warning("dfree %s: free on null pointer.", name); 00083 return; 00084 } 00085 free(ptr); 00086 } 00087 00088 void 00089 free_hash_bucket(struct hash_bucket *ptr, char *name) 00090 { 00091 dfree(ptr, name); 00092 } Generated on Sat May 26 2012 04:22:03 for ReactOS by
1.7.6.1
|