stack

What is a serial version UID used for? [duplicate]

╄→尐↘猪︶ㄣ 提交于 2019-12-23 11:38:08
问题 This question already has answers here : What is a serialVersionUID and why should I use it? (25 answers) Closed 5 years ago . I'm creating a Java application, and when creating an interface to use with an ADT, it finds the need to initialize a random number as an ID number. public class StackFullException extends RuntimeException { private static final long serialVersionUID = 1L; public StackFullException(){} public StackFullException(String message) { super(message); } } I'm curious as to

Reducing stack usage during recursion with GCC + ARM

孤街醉人 提交于 2019-12-23 09:39:31
问题 I have a recursive descent parser for an embedded ARM processor (in C + GCC, for ARM Cortex M3). While running it I've noticed that it uses a massive amount of stack space (even more than you might expect) and under closer inspection I have found that this is happening: extern int bar(int *p); int foo() { int z = foo(); // it's an example! int n[100]; // stack usage return z+bar(n); // calling bar(n) stops n from being optimised out } Result of running arm-none-eabi-gcc -fomit-frame-pointer

Allocating a buffer of more a page size on stack will corrupt memory?

只谈情不闲聊 提交于 2019-12-23 09:37:12
问题 In Windows, stack is implemented as followed: a specified page is followed committed stack pages. It's protection flag is as guarded. So when thead references an address on the guared page, an memory fault rises which makes memory manager commits the guarded page to the stack and clean the page's guarded flag, then it reserves a new page as guarded. when I allocate an buffer which size is more than one page(4KB), however, an expected error haven't happen. Why? 回答1: Excellent question (+1).

C++ Arguments Heap vs Stack

戏子无情 提交于 2019-12-23 09:26:26
问题 Suppose I create two vectors, one on the heap and one on the stack: Vector<int> vector1; Vector<int>* vector2 = new Vector<int>; I then pass vector1 into two functions, say, foo1(Vector<int>) and foo2(Vector<int>&) . I also pass vector2 into foo3(Vector<int>*) . Since I'm new to C++, I'm rather confused by the difference in behaviours here. Am I right to say that for foo1 , the entire vector1 gets copied, and for foo2 , only the reference to vector1 gets passed into the function? But isn't

Stack Empty Exception

本小妞迷上赌 提交于 2019-12-23 09:16:29
问题 I am getting a stack empty exception. How is that possible if the stack is not empty (it has 16 items)? I got a snap shot of the error: Can someone please explain? 回答1: You must synchronize access when using something like Stack<T> . The simplest approach is to use lock , which then also let's you use the lock for the synchronization itself; so pop would be: int item; lock (SharedMemory) { while (SharedMemory.Count == 0) { Monitor.Wait(SharedMemory); } item = SharedMemory.Pop(); } Console

How to avoid adding same fragment to stack

老子叫甜甜 提交于 2019-12-23 08:45:08
问题 I need some help. em adding fragment to activity this way. problem is on each call of openFragment it create fragment and add. which is obvious. Question: what modification i do, so it can add fragment only once. on the next call with same fragment tag it will do nothing. case: press button first time it add fragment and shows. i press again same button it response nothing. public static void openFragment(Activity activity, Fragment fragment) { FragmentManager fragmentManager = (

How to avoid adding same fragment to stack

主宰稳场 提交于 2019-12-23 08:44:24
问题 I need some help. em adding fragment to activity this way. problem is on each call of openFragment it create fragment and add. which is obvious. Question: what modification i do, so it can add fragment only once. on the next call with same fragment tag it will do nothing. case: press button first time it add fragment and shows. i press again same button it response nothing. public static void openFragment(Activity activity, Fragment fragment) { FragmentManager fragmentManager = (

Ruby stack level too deep exception NOT from recursive infinite loop

限于喜欢 提交于 2019-12-23 08:00:12
问题 EDIT : (SOLVED) actually it probably was raised BECAUSE OF an infinite loop I was coding and after adding a method I got this : user_name@the_computer:/media/ECC3-C3B0/Prog/mts/src/mts$ rake test --trace ** Invoke test (first_time) ** Execute test /home/user_name/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36: stack level too deep (SystemStackError) rake aborted! Command failed with status (1): [/home/user_name/.rvm/rubies/ruby-1.9.3-p19...] /home/user_name

Memory allocated with alloca gets freed at end of function or at end of scope?

拜拜、爱过 提交于 2019-12-23 07:31:21
问题 If I have a function like this: void bla(int size) { while(b){ char tmp[size]; ...... } } tmp gets freed at each iteration of the while loop, right? If I write this function: void bla(int size) { while(b){ char* tmp = alloca(size); ...... } } tmp gets freed at end of scope or at end of function? 回答1: It will be freed at end of function, but since you call alloca() inside the loop you'll likely get stack overflow. If size doesn't change within the function you should call alloca() before the

Algorithm for a XOR tree traverse [closed]

余生长醉 提交于 2019-12-23 06:21:28
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I have a binary tree and its internal nodes consist of 'AND' or 'XOR'. Leaf nodes have also and data members. I need to print all possible paths by using stack(non-recursive). I have searched for traversing tree with stack, but its algorithm doesn't hold in my case since postorder,preorder or inorder cannot be