stack

Stack memory in Android

I'm writing an app that has a foreground service, content provider, and a Activity front end that binds to the service and gets back a List of objects using AIDL. The service does work and updates a database. If I leave the activity open for 4-8+ hours, and go to the "Running Services" section under settings on the phone (Nexus One) an ...

problem when trying to empty a stack in c

Hi all, (probably it's a stupid thing but) I have a problem with a stack implementation in C language, when I try to empty it, the function to empty the stack does an infinite loop.. the top of the stack is never null. where I commit an error? thanks bye! #include <stdio.h> #include <stdlib.h> typedef struct stack{ size_t a; struct...

can anybody suggest go-lang container for simple and fast FIFO stack

can anybody suggest go-lang container for simple and fast FIFO stack, go have 3 different container pkg heap, list and vector. which is more suitable to implement FIFO stack? thanks. ...

Class members allocation on heap/stack? C++

If a class is declared as follows: class MyClass { char * MyMember; MyClass() { MyMember = new char[250]; } ~MyClass() { delete[] MyMember; } }; And it could be done like this: class MyClass { char MyMember[250]; }; How does a class gets allocated on heap, like if i do MyClass * Mine = new MyClass(); Does th...

LIFO stack algorithm design

I'm implementing a stack-based VM and I've been trying to read up on literature that explains or outlines algorithms for dealing with stacks no no avail. Here's an example: int i = 3 int j = 4 int k = 5 Lets assume i, j, and k are local variables so they would be traditionally stored on the stack. The assembly/bytecode translation wou...

Processing command-line arguments in prefix notation in Python

I'm trying to parse a command-line in Python which looks like the following: $ ./command -o option1 arg1 -o option2 arg2 arg3 In other words, the command takes an unlimited number of arguments, and each argument may optionally be preceded with an -o option, which relates specifically to that argument. I think this is called a "prefix ...

C++ stack for multiple data types (RPN vector calculator)

Hello: I have designed a quick and basic vector arithmetic library in C++. I call the program from the command line when I need a rapid cross product, or angle between vectors. I don't use Matlab or Octave or related, because the startup time is larger than the computation time. Again, this is for very basic operations. I am extending ...

Thread safety with heap-allocated memory

I was reading this: http://en.wikipedia.org/wiki/Thread_safety Is the following function thread-safe? void foo(int y){ int * x = new int[50]; /*...do some stuff with the allocated memory...*/ delete [] x; } In the article it says that to be thread-safe you can only use variables from the stack. Really? Why? Wouldn't subse...

How to debug anomalous C memory/stack problems

Hello, Sorry I can't be specific with code, but the problems I am seeing are anomalous. Character string values seem to be getting changed depending on other, unrelated code. For example, the value of the argument that is passed around below will change merely depending on if I comment out one or two of the fprintf() calls! By the la...

Total stack sizes of threads in one process

I use pthreads_attr_getthreadsizes() to get default stack size of one thread, 8MB on my machine. But when I create 8 threads and allocate a very large stack size to them, say hundreds of MB, the program crash. So, I guess, shall ("Number of threads" * "stack size per thread") < a constant value (e.g. virtual memory size) ? ...

remove repeated vaules _stack&array

I want to write a program to implement an array-based stack, which accept integer numbers entered by the user.the program will then identify any occurrences of a given value from user and remove the repeated values from the stack,(using Java programming language). I just need your help of writing (removing values method) e.g. input:6 2 ...

Dynamic stack allocation in C++

I want to allocate memory on the stack. Heard of _alloca / alloca and I understand that these are compiler-specific stuff, which I don't like. So, I came-up with my own solution (which might have it's own flaws) and I want you to review/improve it so for once and for all we'll have this code working: /*#define allocate_on_stack(pointe...

Interpreter with a one-register VM - possible to evaluate all math. expressions?

I'm writing an interpreter. I've done that before but never tried one which can work with expressions like 3 + 4 * 2 / ( 1 − 5 ) ^ 2 ^ 3. I'm not having a problem with the parsing process, actually it is about my VM which then executes the code. My goal was a fast interpreter and so I decided not to use a stack-based VM where you would...

Powershell / .Net: Get a reference to an object returned by a method

I am teaching myself PowerShell by writing a simple parser. I use the .Net framework class Collections.Stack. I want to modify the object at the top of the stack in place. I know I can pop() the object off, modify it, and then push() it back on, but that strikes me as inelegant. First, I tried this: $stk = new-object Collections.Sta...

Question about C++ std stack

Can C++ std::stack handle more than 10k int items? And how about its performance? ...

Process with a certain stack size?

Is there a way in C# to start a process with a certain stack size? ...

Checking stack size in C#

Is there a way to check threads stack size in C#? ...

Dojo StackContainer children are not resizing on browser maximise/restore

Hi. I have the following nested layout in a dojo 1.4 app: BorderContainer 1 --> Stack Container 1 -->-->BorderContainer 2 -->-->BorderContainer 3 The StackContainer is sized with width and height 100%. When I resize the browser window using maximise/restore, the StackContainer correctly resizes to the center region of it's parent Bo...

How can I tell if CString allocates memory on the heap or stack?

How can I tell if the MFC CString allocates memory on the heap or stack? I am compiling for the Windows Mobile/Windows CE platform. I am working on a project developed by someone else and I have witnessed stack overflows under certain circumstances. I am trying to figure out if the custom SQLite recordset classes (with many CString ...

Android: How to make launcher always open the main activity instead of child activity? (or otherwise)

I have activities A and B. The A is the one with LAUNCHER intent-filter (i.e. the activity that is started when we click the app icon on home screen). A launches B using startActivity(new Intent(A.this, B.class)). When the user has the B activity open, and then put my application into the background, and later my application's process...