stackavail
Go Up to malloc.h Index
Header File
malloc.h
Prototype
size_t stackavail(void);
Description
Gets the amount of available stack memory.
stackavail returns the number of bytes available on the stack. This is the amount of dynamic memory that alloca can access.
Return Value
stackavail returns a size_t value indicating the number of bytes available.
Portability
POSIX | ANSI C | ANSI C++ | Win32 | Win64 | macOS | |
---|---|---|---|---|---|---|
stackavail | + |
Example
#include <malloc.h>
#include <stdio.h>
int main(void) {
char *buf;
printf("\nThe stack: %u\tstack pointer: %u", stackavail(), _SP);
buf = (char *) alloca(100 * sizeof(char));
printf("\nNow, the stack: %u\tstack pointer: %u", stackavail(), _SP);
return 0;
}