stack-allocation Questions
1
I have the following piece of code:
extern void func1(char *array);
extern void func2(char *array);
void myfunction(void) {
if (somecondition) {
char var2[256];
func2(var2);
}
if (someotherco...
Depravity asked 12/9, 2022 at 17:45
3
As my usually used C++ compilers allow variable-length arrays (e.g. arrays depending on runtime size), I wonder if there is something like std::array with variable size? Of course std::vector is of...
Poeticize asked 31/12, 2013 at 12:42
1
Solved
Consider the following example:
struct vector {
int size() const;
bool empty() const;
};
bool vector::empty() const
{
return size() == 0;
}
The generated assembly code for vector::empty (by ...
Gardie asked 7/1, 2020 at 22:22
1
Solved
Since somewhere around Java 6, the Hotspot JVM can do escape analysis and allocate non-escaping objects on the stack instead of on the garbage collected heap. This results in a speedup of the...
Hizar asked 24/3, 2017 at 14:48
3
Solved
I am porting some C99 code that makes heavy use of variable length arrays (VLA) to C++.
I replaced the VLAs (stack allocation) with an array class that allocates memory on the heap. The performanc...
Mysterious asked 3/4, 2016 at 20:1
7
Solved
In a project about a decade ago, we found that std::vector's dynamic allocations caused a serious performance drain. In this case it was many small vectors allocated, so the quick solution was to w...
Chil asked 14/10, 2014 at 8:47
1
© 2022 - 2024 — McMap. All rights reserved.