stack

Windows assembly heap and stack?

OS: Windows 7 32bit So in like c++ one has a heap and a stack. But i've been starting on some assembly learning lately and haven't seen anything of the sort, only a stack but it just looks like pure memory. So is heap and stack implementation specific for c++ and other languages? Or do you still get allocated a heap and stack in assemb...

Calling cdecl Functions That Have Different Number of Arguments

I have functions that I wish to call based on some input. Each function has different number of arguments. In other words, if (strcmp(str, "funcA") == 0) funcA(a, b, c); else if (strcmp(str, "funcB") == 0) funcB(d); else if (strcmp(str, "funcC") == 0) funcC(f, g); This is a bit bulky and hard to maintain. Ideally, these are variadic f...

Object Serialization for Undo/Redo Functionality Java

I have been trying to implement and undo/redo system in a game I am coding in Java. I am taking the approach of serializing the state of the game after each move. I there a way of saving the serialized objects on a stack and accessing them for undo/redo? ...

Beginner learning assembly preserving esp after function calls

I'm a beginner learning some assembly, when preserving the ESP register before a function call does it matter if you do it by adding or subtracting? hard to explain, consider the following mov esi, esp sub esp, 12 // on 32bit OS this would mean that there are 3 arguments to the function // push, function call etc cmp esi, esp // should ...

Are destructors of automatic objects invoked when terminate is called?

I'm pondering a question on Brainbench. I actually realised that I could answer my question easily by compiling the code, but it's an interesting question nonetheless, so I'll ask the question anyway and answer it myself shortly. Take a look at this snippet: The question considers what happens when we throw from a destructor (which c...

Basic Java Multi-Threading Question

When an object is instantiated in Java, is it bound to the thread that instantiated in? Because when I anonymously implement an interface in one thread, and pass it to another thread to be run, all of its methods are run in the original thread. If they are bound to their creation thread, is there anyway to create an object that will run ...

How to make Stack.Pop threadsafe

I am using the BlockingQueue code posted in this question, but realized I needed to use a Stack instead of a Queue given how my program runs. I converted it to use a Stack and renamed the class as needed. For performance I removed locking in Push, since my producer code is single threaded. My problem is how can thread working on the (...

Are stack based arrays possible in C#?

Let's say, hypothetically (read: I don't think I actually need this, but I am curious as the idea popped into my head), one wanted an array of memory set aside locally on the stack, not on the heap. For instance, something like this: private void someFunction() { int[20] stackArray; //C style; I know the size and it's set in stone }...

Hibernate - on the stack or on the heap?

As a Java programmer, you usually keep two truths in your pocket: Instance variables and Objects lie on Heap. Local variables and methods lie on the Stack. Now that I use Hibernate in just about everything, I realize I'm not as sure of myself. Are there some good rules of thumb for using hibernate and knowing where your memory liv...

Stack buffer overrun (Windows, C++) : how can I detect the culprit?

Are there any tools/libraries on Windows that can help me tarck down the culprit? This is a fairly large codebase, with multiple threads. I code for Linux mostly; Windows is unfamiliar territory. Thanks for your input. ...

How to implement a graph-structured stack?

Ok, so I would like to make a GLR parser generator. I know there exist such programs better than what I will probably make, but I am doing this for fun/learning so that's not important. I have been reading about GLR parsing and I think I have a decent high level understanding of it now. But now it's time to get down to business. The gr...

How can I get JUnit test (driven from Ant script) to dump the stack of exception that causes failure?

We run JUnit test from Ant script, as follows. When the test failed, I expect it to output the stack dump of the exception that casuses the failure, but it doesn't. Is there any trick to get it dumped? <target description="Run JUnit tests" name="run-junit" depends="build-junit"> <copy file="./AegisLicense.txt" tofile="test/junit/c...

Core Data - Limiting number of saved objects

Hi! Is there way to limit the number of saved objects in coredata like stack, where the last objects are automatically deleted? ...

Recursive stack size

How i can know the current method stack frame while a recursive call in ruby? ...

Why so much stack space used for each recursion?

I have a simple recursive function RCompare() that calls a more complex function Compare() which returns before the recursive call. Each recursion level uses 248 bytes of stack space which seems like way more than it should. Here is the recursive function: void CMList::RCompare(MP n1) // RECURSIVE and Looping compare function { auto M...

Linux TCP stack packet injection

Could i inject packets to Linux TCP stack without modifying the ethernet driver? Could i do this with using a library or sth ? Thank you, ...

A very basic auto-expanding list/array

Hi, I have a method which returns an array of fixed type objects (let's say MyObject). The method creates a new empty Stack<MyObject>. Then, it does some work and pushes some number of MyObjects to the end of the Stack. Finally, it returns the Stack.ToArray(). It does not change already added items or their properties, nor remove them...

What's the best general programming book to review basic development concepts?

I'm looking for for a programming book that reviews basic concepts like implementing linked lists, stacks, queues, hash tables, tree traversals, search algorithms, etc. etc. Basically, I'm looking for a review of everything I learned in college but have forgotten. I prefer something written in the last few years that includes at least a ...

Does a garbage collector collect stack memory, heap memory, or both?

I read lot of articles about garbage collection and almost all article tells about heap memory. so my question is "garbage collection collects stack memory or heap memory or both". thanks Kalpesh ...

Scaling an iterative, bitwise algorithm to solve the Towers of Hanoi using X discs and Y towers

I like the algorithm mentioned in this question: "How does this work? Weird Towers of Hanoi Solution" http://stackoverflow.com/questions/2209860/how-does-this-work-weird-towers-of-hanoi-solution Is there any way to scale that non-recursive solution of Towers of Hanoi to use X disks and Y towers, with towers represented as stacks? ...