valloc.c revision 92986
1158115Sume/* 2158115Sume * Copyright (c) 1980, 1993 3158115Sume * The Regents of the University of California. All rights reserved. 4158115Sume * 5158115Sume * Redistribution and use in source and binary forms, with or without 6158115Sume * modification, are permitted provided that the following conditions 7158115Sume * are met: 8158115Sume * 1. Redistributions of source code must retain the above copyright 9158115Sume * notice, this list of conditions and the following disclaimer. 10158115Sume * 2. Redistributions in binary form must reproduce the above copyright 11158115Sume * notice, this list of conditions and the following disclaimer in the 12158115Sume * documentation and/or other materials provided with the distribution. 13158115Sume * 3. All advertising materials mentioning features or use of this software 14158115Sume * must display the following acknowledgement: 15158115Sume * This product includes software developed by the University of 16158115Sume * California, Berkeley and its contributors. 17158115Sume * 4. Neither the name of the University nor the names of its contributors 18158115Sume * may be used to endorse or promote products derived from this software 19158115Sume * without specific prior written permission. 20158115Sume * 21158115Sume * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22158115Sume * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23158115Sume * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24158115Sume * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25158115Sume * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26158115Sume * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27158186Smatteo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28171795Sbushman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29158115Sume * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30158115Sume * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31171795Sbushman * SUCH DAMAGE. 32171795Sbushman */ 33162893Sru 34162893Sru#if defined(LIBC_SCCS) && !defined(lint) 35158115Sumestatic char sccsid[] = "@(#)valloc.c 8.1 (Berkeley) 6/4/93"; 36162893Sru#endif /* LIBC_SCCS and not lint */ 37158115Sume#include <sys/cdefs.h> 38171795Sbushman__FBSDID("$FreeBSD: head/lib/libc/gen/valloc.c 92986 2002-03-22 21:53:29Z obrien $"); 39158188Smaxim 40162893Sru#include <stdlib.h> 41162893Sru#include <unistd.h> 42162893Sru 43162893Sruvoid * 44162893Sruvalloc(i) 45162893Sru size_t i; 46162893Sru{ 47158115Sume long valsiz = getpagesize(), j; 48162893Sru void *cp = malloc(i + (valsiz-1)); 49162893Sru 50162893Sru j = ((long)cp + (valsiz-1)) &~ (valsiz-1); 51162893Sru return ((void *)j); 52162893Sru} 53162893Sru