valloc.c revision 154252
150764Smarkm/* 250764Smarkm * Copyright (c) 1980, 1993 350764Smarkm * The Regents of the University of California. All rights reserved. 450764Smarkm * 550764Smarkm * Redistribution and use in source and binary forms, with or without 650764Smarkm * modification, are permitted provided that the following conditions 750764Smarkm * are met: 850764Smarkm * 1. Redistributions of source code must retain the above copyright 950764Smarkm * notice, this list of conditions and the following disclaimer. 1050764Smarkm * 2. Redistributions in binary form must reproduce the above copyright 1150764Smarkm * notice, this list of conditions and the following disclaimer in the 1250764Smarkm * documentation and/or other materials provided with the distribution. 1350764Smarkm * 3. All advertising materials mentioning features or use of this software 1450764Smarkm * must display the following acknowledgement: 1550764Smarkm * This product includes software developed by the University of 1650764Smarkm * California, Berkeley and its contributors. 1750764Smarkm * 4. Neither the name of the University nor the names of its contributors 1850764Smarkm * may be used to endorse or promote products derived from this software 1950764Smarkm * without specific prior written permission. 2050764Smarkm * 2150764Smarkm * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2250764Smarkm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2350764Smarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2450764Smarkm * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2550764Smarkm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2650764Smarkm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2750764Smarkm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2850764Smarkm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2950764Smarkm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3050764Smarkm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3150764Smarkm * SUCH DAMAGE. 3250764Smarkm */ 3350764Smarkm 3450764Smarkm#if defined(LIBC_SCCS) && !defined(lint) 3550764Smarkmstatic char sccsid[] = "@(#)valloc.c 8.1 (Berkeley) 6/4/93"; 3650764Smarkm#endif /* LIBC_SCCS and not lint */ 3750764Smarkm#include <sys/cdefs.h> 3850764Smarkm__FBSDID("$FreeBSD: head/lib/libc/gen/valloc.c 154252 2006-01-12 09:29:38Z jasone $"); 3950764Smarkm 4050764Smarkm#include <stdlib.h> 4150764Smarkm#include <unistd.h> 4250764Smarkm 4350764Smarkmvoid * 4450764Smarkmvalloc(size_t i) 4550764Smarkm{ 4650764Smarkm void *ret; 4750764Smarkm 4850764Smarkm if (posix_memalign(&ret, getpagesize(), i) != 0) 4950764Smarkm ret = NULL; 5050764Smarkm 5150764Smarkm return ret; 5250764Smarkm} 5350764Smarkm