stack

Accessing the Java call stack

I would like to know if it's possible to access the call stack from within a method to see which method in which package called the one we are in now? Or perhaps there is another way of doing this? Thanks, ExtremeCoder P.S. This is all in Java ...

recursive + 900 elements + neighbor check = causes stackoverflow

Hi, I have a city simulation game and try to find a way to check the flow of our power system. The basics: The map for the city is based on tiles (30 by 30 tiles = 900 tiles). Now i start at a power plant and do a recursive neighbor check (top, left, right, bottom) to check if there is something that will transport the power. If there i...

Is it possible to Merge stacks with LINQ

I'm just starting to learn LINQ, I'm wondering if it would be possible to group the elements in 3 different stacks using LINQ. this is what I have, could it be possible to add more than one array in the from clause, and how? var uniqueValues = from n in valuesStack.ToArray() group n by n into nGroup ...

Variable stack size

My system (linux kernel 2.6.32-24) is implementing a feature named Address Space Layout Randomization (ASLR). ASLR seems to change the stack size: void f(int n) { printf(" %d ", n); f(n + 1); } int main(...) { f(0); } Obviously if you execute the program you'll get a stack overflow. The problem is that segmentation fault...

See any problems with this C# implementation of a stack?

I wrote this quickly under interview conditions, I wanted to post it to the community to possibly see if there was a better/faster/cleaner way to go about it. How could this be optimized? using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Stack { class StackElement<T> { publi...

The direction of stack growth and heap growth

In some systems, the stack grows in upward direction whereas the heap grows in downward direction and in some systems, the stack grows in downward direction and the heap grows in upward direction. But, Which is the best design ? Are there any programming advantages for any of those two specific designs ? Which is most commonly used and w...

Getting the name of the calling function in C (without using the preprocessor).

Hello, I was wondering if there is a way of finding which function called the current function (at runtime) in C. I know you could use __FUNCTION__ in gcc, but is there a way without using the C preprocessor? Probably not. Cheers ...

In which cases is alloca() useful?

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... ...

comparison of access performance of data in heap and stack

It is widely known common sense, that for most algorithms, allocating and deallocating data on the stack is much faster than doing so on the heap. In C++, the difference in the code is like double foo[n*n] vs. double* foo = new int[n*n] But there are any significant differences, when it comes to accessing and calculating with data ...

Diffrence between stack memory and heap memory

Possible Duplicate: What and where are the stack and heap Where is heap memory and stack memory stored?I mean where on the harddisk?what are the limits of their size? ...

Why can't I declare bitfields as automatic variables?

I want to declare a bitfield with the size specified using the a colon (I can't remember what the syntax is called). I want to write this: void myFunction() { unsigned int thing : 12; ... } But GCC says it's a syntax error (it thinks I'm trying to write a nested function). I have no problem doing this though: struct thingStru...

Why is it necessary to load every argument onto the stack in CIL method?

Hi, in my application I need to dynamically create a type that contains multiple properties. I am aware that in cases such as this, one has to generate an CIL for both getter and setter methods of a property by using an ILGenerator. More by a trial and error than anything else, I've finally arrived to the following code that generates ...

Clear the entire history stack and start a new activity on Android

Is it possible to start an activity on the stack, clearing the entire history before it? The situation I have an activity stack that either goes A->B->C or B->C (screen A selects the users token, but many users only have a single token). In screen C the user may take an action which makes screen B invalid, so the application wants to...

Does initialized java array go onto stack or heap?

void someMethod() { byte[] array = { 0, 0 }; } Will this array be stored in heap or on the stack? ...

Why won't int variable come before char array in terms of addressing no matter how I code it in C?

I'm reading Hacking: The Art of Exploitation (2nd Edition), and I'm currently on the section about buffer overflows. In the first example, the variables are declared/initialized in this order: int auth_flag = 0; char password_buffer[16]; The example goes on to explain that you can use gdb to examine auth_flag and password_buffer's ad...

+= appends to stack in Scala 2.7.7; :+ does not seem to work in Scala 2.8.0

Using Scala 2.7.7, this works as expected: import scala.collection.mutable.Stack ... var x = new Stack[String] x += "Hello" println(x.top) After changing to Scala 2.8.0, the += should be replaced by :+. However, this does not append to the stack: java.util.NoSuchElementException: head of empty list. Am I overlooking something basic? ...

Is there any list and comparison of different network stacks for Linux/Unix?

I noticed there is LWIP, a light weight TCP/IP stack for embedded systems. So I am wondering are there any other network stacks, which can replace the default Linux stack? And how do they perform? What's the pros and cons of them? THX! --wbsun ...

Postfix -expression evaluation

i am trying to write program for evaluate Postfix-expression code: #include <iostream> #include <cstring> #include <stack> #include <ostream> using namespace std; int main(int argc,char *argv[]){ char *a=argv[1]; int n=strlen(a); stack<int>s; for (int i=0;i<n;i++) { if (a[i]=='+') s.push(s.pop()+s.pop...

Why is this code exiting prematurely?

#include <stdio.h> #define MAX 5 int stk[MAX]; int top=-1; main() { char ch; void push(); void pop(); void display(); do { printf("1. Push\n"); printf("2. Pop\n"); printf("3. Display\n"); ch=getchar(); if(ch=='1') push(); i...

Windows Vista+ Memory Problem with IFileOpenDialog and large stack

I have experienced a strange problem in windows vista and above. When I use the IFileOpenDialog with a large stack, the amount of memory remaining after showing the dialog drops by about a gigabyte. #include <windows.h> #include <Shobjidl.h> #include <iostream> void memGrab(char *); int main(int argc, char **argv){ char Message[128];...