valloc.c revision 331722
1233294Sstas/*
255682Smarkm * Copyright (c) 1980, 1993
3178825Sdfr *	The Regents of the University of California.  All rights reserved.
4233294Sstas *
578527Sassar * Redistribution and use in source and binary forms, with or without
678527Sassar * modification, are permitted provided that the following conditions
778527Sassar * are met:
855682Smarkm * 1. Redistributions of source code must retain the above copyright
978527Sassar *    notice, this list of conditions and the following disclaimer.
1078527Sassar * 2. Redistributions in binary form must reproduce the above copyright
1178527Sassar *    notice, this list of conditions and the following disclaimer in the
1278527Sassar *    documentation and/or other materials provided with the distribution.
1355682Smarkm * 4. Neither the name of the University nor the names of its contributors
14233294Sstas *    may be used to endorse or promote products derived from this software
15233294Sstas *    without specific prior written permission.
16233294Sstas *
17233294Sstas * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18233294Sstas * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19233294Sstas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20233294Sstas * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21178825Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22233294Sstas * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23102644Snectar * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24178825Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25178825Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26178825Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2755682Smarkm * SUCH DAMAGE.
28142403Snectar */
29142403Snectar
30142403Snectar#if defined(LIBC_SCCS) && !defined(lint)
31142403Snectarstatic char sccsid[] = "@(#)valloc.c	8.1 (Berkeley) 6/4/93";
32178825Sdfr#endif /* LIBC_SCCS and not lint */
33178825Sdfr#include <sys/cdefs.h>
34233294Sstas__FBSDID("$FreeBSD: stable/11/lib/libc/gen/valloc.c 331722 2018-03-29 02:50:57Z eadler $");
35178825Sdfr
36178825Sdfr#include <stdlib.h>
37233294Sstas#include <unistd.h>
38178825Sdfr
39178825Sdfrvoid *
40103423Snectarvalloc(size_t i)
41178825Sdfr{
42178825Sdfr	void	*ret;
43178825Sdfr
44178825Sdfr	if (posix_memalign(&ret, getpagesize(), i) != 0)
45178825Sdfr		ret = NULL;
46178825Sdfr
47178825Sdfr	return ret;
48142403Snectar}
49142403Snectar