valloc(3)
β¨ valloc(3) β¨
okay bestie, pull up a chair because we're talking about valloc from the Library Functions Manual and honestly? she's a legacy icon but she's also kinda retired, so let's get into it π
NAME π
valloc β page-aligned memory allocation
no cap, that's literally the whole job. she hands you memory, but the address is all fancy and page-aligned β¨
LIBRARY π¦
Standard C library β link it with -lc, bestie. as usual π«Ά
SYNOPSIS πΈ
#include <stdlib.h>
[[deprecated]] void *valloc(size_t size);
see that [[deprecated]]? yeah. she's marked. the compiler is gonna side-eye you. it's giving "we still support her but we're not happy about it" π
Feature Test Macro Requirements for glibc π
(if you need the full lore on these, go read feature_test_macros(7), she explains everything)
valloc():
Since glibc 2.12:
(_XOPEN_SOURCE >= 500) && !(_POSIX_C_SOURCE >= 200112L)
|| /* glibc >= 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _SVID_SOURCE || _BSD_SOURCE
Before glibc 2.12:
_BSD_SOURCE || _XOPEN_SOURCE >= 500
okay so the way that you get her declared is very glibc-version-dependent, so check your macros before you start crying about implicit declarations π
DESCRIPTION π
so valloc() allocates size bytes and hands back a pointer to that allocated memory. but here's the flex: the memory address is gonna be a multiple of the page size. every time. no exceptions. main character alignment energy π
she's literally equivalent to:
memalign(sysconf(_SC_PAGESIZE),size)
same thing, different font. periodt.
ATTRIBUTES β
if you're confused about what "attributes" even means here, attributes(7) has you covered, bestie.
- Interface:
valloc() - Attribute: Thread safety
- Value:
MT-Unsafe init
so... not thread safe on init. be careful out there π
VERSIONS π
okay so per SUSv2, valloc() is declared in <stdlib.h>.
glibc, being extra, declares it in <malloc.h> β and also in <stdlib.h>, but only if you've defined the right feature test macros (scroll up, they're right there β¨).
STANDARDS π
BSD, GNU.
that's the whole list. she's a two-house icon π
HISTORY π
- glibc 2.0.
- 3.0BSD.
- Documented as obsolete in 4.3BSD π
- Documented as legacy in SUSv2
so yeah, she's been around for a minute, and the docs have been gently roasting her basically the entire time. iconic behaviour honestly π«Ά
CAVEATS π₯
go look at memalign(3). that's where the real warnings live, bestie. don't skip it π
SEE ALSO π¦
and that's the whole page, bestie!! mwah π
this little time capsule comes to you from Linux man-pages 6.20, dated 2025-12-13, and yes she's still filed under valloc(3) after all these years β legacy queen, we love her πβ¨
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms