stack

How to manage activity stack?

自闭症网瘾萝莉.ら 提交于 2019-12-09 15:26:54
问题 When my stack is in this situation: A->B->C if I start D activity, I want that the activity stack becomes: A->D Note that activity C is a dialog. 回答1: here are the steps which will do the needed: from activity C launch the activity A with a boolean fromActivityC bundled with the intent and the flag FLAG_ACTIVITY_CLEAR_TOP set . Now in the on create of the activity A check for this boolean "fromActivityC" first and if present launch the activity D else the normal flow continues. // following

C++ jump to other method execution

馋奶兔 提交于 2019-12-09 14:52:45
问题 In my C++ JNI-Agent project i am implementing a function which would be given a variable number of parameters and would pass the execution to the other function: // address of theOriginalFunction public static void* originalfunc; void* interceptor(JNIEnv *env, jclass clazz, ...){ // add 4 to the function address to skip "push ebp / mov ebp esp" asm volatile("jmp *%0;"::"r" (originalfunc+4)); // will not get here anyway return NULL; } The function above needs to just jump to the: JNIEXPORT

How do I create an array in C++ which is on the heap instead of the stack?

蹲街弑〆低调 提交于 2019-12-09 14:48:03
问题 I have a very large array which must be 262144 elements in length (and potentially much larger in future). I have tried allocating the array on the stack like so: #define SIZE 262144 int myArray[SIZE]; However, it appears that when I try and add elements past a certain point, the values are different when I try to access them. I understand that this is because there is only a finite amount of memory on the stack, as opposed to the heap which has more memory. I have tried the following without

Linked list vs dynamic array for implementing a stack using vector class

旧城冷巷雨未停 提交于 2019-12-09 12:48:00
问题 I was reading up on the two different ways of implementing a stack: linked list and dynamic arrays. The main advantage of a linked list over a dynamic array was that the linked list did not have to be resized while a dynamic array had to be resized if too many elements were inserted hence wasting alot of time and memory. That got me wondering if this is true for C++ (as there is a vector class which automatically resizes whenever new elements are inserted)? 回答1: It's difficult to compare the

SystemStackError (stack level too deep)

夙愿已清 提交于 2019-12-09 12:13:02
问题 I'm developing an android app, and I need to have a json response of the show view about a saved object. Trying that, I receive: "SystemStackError (stack level too deep)" app/controllers/segnalaziones_controller.rb:74:in `create' app/controllers/segnalaziones_controller.rb:58:in `create' Here is the "Segnalazione" controller include Gft class SegnalazionesController < ApplicationController load_and_authorize_resource respond_to :json # GET /segnalaziones # GET /segnalaziones.xml # before

Pushing a Lua table

柔情痞子 提交于 2019-12-09 11:47:48
问题 I have created a Lua table in C , but I'm not sure how to push that table onto the top of a stack so I can pass it to a Lua function. Does anyone know how to do this? This is my current code: lua_createtable(state, libraries.size(), 0); int table_index = lua_gettop(state); for (int i = 0; i < libraries.size(); i++) { lua_pushstring(state, libraries[i].c_str()); lua_rawseti(state, table_index, i + 1); } lua_settable(state, -3); [ Push other things ] [ Call function ] 回答1: Here's a quick helper

Navigating Java call stack in Eclipse

♀尐吖头ヾ 提交于 2019-12-09 07:33:22
问题 In debuggers like GDB, when you stop at a breakpoint, you can easily move up the call stack and examine the relevant source and stack frame data. How do you do this in Eclipse? 回答1: In the "debug perspective", show the view named "debug". For each thread that is currently halted, this view shows the full call stack. Clicking on one element of this stack switches the editor view to display the corresponding class, and "variables" view will show variables of this stack element. 回答2: Note that

x86_64 align stack and recover without saving registers

旧街凉风 提交于 2019-12-09 06:32:02
问题 I'm writing interrupt handling routines for x86_64. The ABI specifies that before calling a C function I must align the stack to 16 bytes. The x86_64 ISA specifies that on entry to an ISR, my stack is 8 byte aligned. I need to align my stack pointer to 16 bytes therefore. The issue is that on return from my C function, I must recover the (potentially) unaligned stack pointer so that I can return from my interrupt correctly. I wonder if there is a way to do this without using a general purpose

What is the difference between kernel stack and user stack?

我与影子孤独终老i 提交于 2019-12-09 04:06:54
问题 What is the need of using two different stacks in same program? How does trap change the current stack of program from user stack to kernel stack? How does it come back to user stack after completing system call? Does every process have a kernel and user stack? 回答1: There is one "kernel stack" per CPU. There is one "user stack" for each process, though each thread has its own stack, including both user and kernel threads. How "trapping changes the stack" is actually fairly simple. The CPU

Write a program to sort a stack in ascending order

帅比萌擦擦* 提交于 2019-12-09 03:31:12
问题 Can someone help look at my code, please? Thank you so much for your help. The input stack is [5, 2, 1, 9, 0, 10], my codes gave output stack [0, 9, 1, 2, 5, 10], 9 is not in the right position. import java.util.*; public class CC3_6 { public static void main(String[] args) { int[] data = {5, 2, 1, 9, 0, 10}; Stack<Integer> myStack = new Stack<Integer>(); for (int i = 0; i < data.length; i++){ myStack.push(data[i]); } System.out.println(sortStack(myStack)); } public static Stack<Integer>