stack

Move value from local stack to heap? (C++)

▼魔方 西西 提交于 2019-12-04 22:20:15
How can I take an object-as-value result from a method call and place it on the heap? For instance: The Qt QImage::scaledToWidth method returns a copy of the QImage object. Right now I'm doing: QImage *new_img_on_heap = new QImage(old_imgage_on_heap->scaledToWidth(2000)); Is this the only way? Seems like it's going through the trouble of making a 3rd whole new object when I already have a perfect good one on the stack. The reason I want to put it on the heap is because the real QImage is large, and I want it to outlive the lifetime of the current method. I was intending to stuff a pointer to

Stack and Stack Base Address

你说的曾经没有我的故事 提交于 2019-12-04 20:37:35
In the MEMORY_BASIC_INFORMATION structure one finds two PVOID variables, called BaseAddress and AllocationBase respectively. I'm reading a book on Threading and its going over how to get the stackspace left on the stack in quite some detail, however there's something I'm not sure I understand correctly. The BaseAddress in the structure mentioned above, does it point to the highest address in the current thread stack or the lowest address? Since the stack grows downwards, the lowest would be at the top and the highest at the bottom. What exactly is the difference between the AllocationBase and

How big is the stack memory for a certain program, and are there any compiler flags that can set it?

允我心安 提交于 2019-12-04 20:11:30
问题 As the title states: Is there any general "rule of thumb" about the size of the stack. I'm guessing the size will vary depending on the OS, the architecture, the size of the cache(s), how much RAM is available etc. However can anything be said in general, or is there any way to find out, how much of the stack, this program is allowed to use?. As a bonus question is there any way (with compiler flags etc. (thinking mostly C/C++ here, but also more general)) that the size of the stack can be

Lisp expression evaluator in Java (using only one stack)

爱⌒轻易说出口 提交于 2019-12-04 19:45:43
I'm trying to implement a simple Lisp expression evaluator using Java. There's actually a wealth of information on the subject, but it appears they all use two separate stacks to arrive at the result. I'm wondering if it is possible to implement such a program using only one stack and what some pseudo code might look like for that. Thanks. For more info on what I'm talking about refer to http://www.chegg.com/homework-help/questions-and-answers/outline-given-import-javautil-public-class-simplelispexpressionevaluator-current-input-lis-q2332957 http://stdioe.blogspot.ca/2012/01/lets-implement

Why should pop() take an argument?

戏子无情 提交于 2019-12-04 19:08:05
问题 Quick background I'm a Java developer who's been playing around with C++ in my free/bored time. Preface In C++, you often see pop taking an argument by reference: void pop(Item& removed); I understand that it is nice to "fill in" the parameter with what you removed. That totally makes sense to me. This way, the person who asked to remove the top item can have a look at what was removed. However, if I were to do this in Java, I'd do something like this: Item pop() throws StackException; This

erlang call stack

a 夏天 提交于 2019-12-04 18:49:28
问题 i need to debug some module in foreign system, module has public function foo() - how can I know place (module and function name) from which foo() given module was called? I mean stack of calls. PS: I cannot stop system, all work I can do by reload this module (but with som debug info) -module(given). -export(foo/0). foo() -> %% here is my debug - and i need here(!) known about unknown_module:unknown_foo! ok. --- -module(unknown_module). .. unknown_foo() -> given:foo(). %% see above 回答1: Here

Get notified when a view controller is about to be popped in iOS4

橙三吉。 提交于 2019-12-04 18:16:20
问题 This question has been asked before, but the answered ones I could find were from 2009 and don't suit my problem. Let me reiterate the issue. I have a UINavigationController that spawns and pushes lots of different UIViewController s onto its stack. One of those deals with some Core Data operations that need to be saved when that one particular VC get's popped off the stack. Don't focus on the Core Data part, it's about the popping. How can I hook into the moment that the UIViewController is

How to convert int to const int to assign array size on stack?

假装没事ソ 提交于 2019-12-04 17:45:49
问题 I am trying to allocate a fixed size on stack to an integer array #include<iostream> using namespace std; int main(){ int n1 = 10; const int N = const_cast<const int&>(n1); //const int N = 10; cout<<" N="<<N<<endl; int foo[N]; return 0; } However, this gives an error on the last line where I am using N to define a fixed error C2057: expected constant expression . However, if I define N as const int N = 10 , the code compiles just fine. How should I typecast n1 to trat it as a const int ? I

Bug : Theme.Translucent & FLAG_ACTIVITY_REORDER_TO_FRONT

时间秒杀一切 提交于 2019-12-04 16:12:24
问题 I have an activity with the translucent Theme : android:theme="@android:style/Theme.Translucent.NoTitleBar" Also the problem is reproduceable with just this Theme: <style name="MyTheme" parent="@android:style/Theme"> <item name="android:windowIsTranslucent">true</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:colorBackground">@null</item> </style> This activity is loaded at startup and kept in memory (when I start this activity, I ad the FLAG

MySQL table as a FIFO/Queue

时光怂恿深爱的人放手 提交于 2019-12-04 15:28:06
How can we treat a Mysql table as a limited FIFO buffer (Queue). Objectives are : The table at a time can have only N number of rows. When a row is inserted, the oldest row shpuld be deleted to maintain the row count as N. Pls suggest approaches. UPDATE: Sorry guys, as many pointed I changed my question from STACK to FIFO queue Past Mysql 5 you could use a trigger to achieve this. http://dev.mysql.com/doc/refman/5.0/en/create-trigger.html then your triggered sql would be along the lines off: DELETE FROM foo WHERE id NOT IN (SELECT id FROM foo ORDER BY id DESC LIMIT 10) You can just get count