alloca Questions
2
The GCC C++ compiler (any many other C++ compilers as well) provide nonstandard extentions such as
alloca() for stack based allocation
variable length arrays, as they are part of the C standard
C...
Acrobatic asked 17/5, 2021 at 19:47
12
Solved
How does one implement alloca() using inline x86 assembler in languages like D, C, and C++? I want to create a slightly modified version of it, but first I need to know how the standard version is ...
Hawse asked 3/4, 2009 at 16:28
4
Solved
I'm trying to figure out how alloca() actually works on a memory level. From the linux man page:
The alloca() function allocates size bytes of space in the stack
frame of the caller. This temporar...
Pistole asked 1/10, 2021 at 13:46
24
Solved
alloca() allocates memory on the stack rather than on the heap, as in the case of malloc(). So, when I return from the routine the memory is freed. So, actually this solves my problem of freeing up...
Greenland asked 19/6, 2009 at 16:24
1
Background (there may be a better way to do this):
I am developing a Julia library in which I manually manage memory; I mmap a large block, and then mostly treat it like a stack: functions receive ...
Surmise asked 13/11, 2019 at 16:16
2
Solved
I can't see any alloca.h equivalent in Visual C 2010. How can one perform stack allocation in Visual C on Windows? I miss the function alloca.
Jin asked 15/7, 2011 at 9:10
2
Solved
Memory allocated by malloc can be reallocated with realloc. Is there a similar function for alloca? Reallocating stack memory could be useful when you don't want memory to be allocated on the heap,...
Cambria asked 31/5, 2019 at 10:5
3
Solved
I was under the impression that alloc in Objective-C (when we invoke [anyObject alloc] is actually implementing C function malloc and the memory getting allocated in heap, but could not find anywhe...
Government asked 21/9, 2015 at 0:50
3
Solved
The C standard prohibits a goto into a function scope where a VLA exists.
A VLA and the call to alloca function should have the same result on low level.
(I could be wrong, as I'm just a C, not a...
Egin asked 23/5, 2014 at 7:22
6
Solved
I'm looking for a way to wrap stack allocations in abstract data types. For example, I'd like to have a vector which can work strictly via allocations on the stack. My biggest hurdle of course is t...
2
See this test program:
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
if (argc < 2)
goto end;
char s[strlen(argv[1]) + 1];
strcpy(s, argv[1]);
prin...
Found asked 2/6, 2017 at 15:29
1
Solved
Quoting the second paragraph of BUGS section, from manpage of alloca(3)
On many systems alloca() cannot be used inside the list of arguments of a function call, because the stack
space reserved...
Dorn asked 29/1, 2017 at 10:3
6
Solved
Why would you ever want to use alloca() when you could always allocate a fixed size buffer on the stack large enough to fit all uses? This is not a rhetorical question...
12
Solved
There are certain conditions that can cause stack overflows on an x86 Linux system:
struct my_big_object[HUGE_NUMBER] on the stack. Walking through it eventually causes SIGSEGV.
The alloca() rout...
3
Solved
My stackAlloc function looks like this:
void* stackAlloc(size_t size) {
if (size > maxStackAllocation)
return malloc(size);
else
return _alloca(size);
}
void stackAllocFree(void *ptr, size...
2
Solved
In my opinion, hiding the definition of a structure in C generally makes code safer, as you enforce—with the help of the compiler—that no member of the structure can be accessed directly.
However, ...
Yttria asked 15/12, 2015 at 22:14
3
Solved
I was revising C and came across to alloca/free functions which is described as allocating storage on a stack like space. Is this same as the malloc/free ? or this is something different ? Thanks.
...
3
Solved
I have the following function:
double
neville (double xx, size_t n, const double *x, const double *y, double *work);
which performs Lagrange interpolation at xx using the n points stored in x a...
1
Solved
I just read that windows programs call _alloca on function entry to grow the stack if they need more than 4k on the stack. I guss that every time the guard page is hit windows allocates a new page ...
2
I have two questions:
1) Is it possible to implement an allocator that uses alloca to allocate memory on the stack and is otherwise C++ STL compliant?
If there is code out there, you can make me ...
2
I've read quite a few places that alloca is obsolete and should not be used and Variable Length Arrays should be used instead.
My question is this: Is alloca completely replaceable by variable le...
4
Solved
For some reason, I should use gcc to compile a C file, then link against Visual C++ 2008 project.
(I used the current latest gcc version: cygwin gcc 4.3.4 20090804.)
But there is one problem: gcc...
Quintinquintina asked 27/2, 2010 at 16:59
6
Solved
What is the difference between
void *bytes = alloca(size);
and
char bytes[size]; //Or to be more precise, char x[size]; void *bytes = x;
...where size is a variable whose value is unknown at ...
Enphytotic asked 10/4, 2010 at 19:2
2
Solved
Is alloca part of the C++ standard?
2
Solved
I've been looking at some LLVM assembly produced by llvm-gcc lately and I've noticed a recurring statement of which I'm not sure its purpose.
For example, the following C program:
int main(void)
...
1 Next >
© 2022 - 2025 — McMap. All rights reserved.