I recently read a lot about "preventing heap allocation for a class" (see this question).
I was able to understand "how", but now I can't figure out "why" someone would like to do that.
I guess there must be legitimate reasons for this, but I just can't figure them out.
In short: "Why may I want to forbid users from creating objects o...
Correction:
I messed up with the concept of pointer address and the address the pointer points to, so the following code has been modified. And now it prints out what I want, variable a, c, i, j, k, p are on the stack, and variable b,d are on the heap. Static and global variables are on another segment. Thanks a lot for all of you!
...
I can't really make a short yet descriptive title to explain my problem, so sorry for that.
I'm calling a lua function called hook.Call(event, ...) from c++. It calls all functions added with hook.Add(event, unique_name, function)
The problem is that when I call the print(...) function inside a hook it won't print what you'd expect it ...
Hello everyone,
I have a strange problem with the UINavigationController.
I wrote an App to display data in three levels. (RootView: Select Data I, Second View: Select Data II, Third View: Display Data). This works great, no problems.
The problem appears when a PushMessage arrives: In this case I'm trying to create a viewController St...
Hello,
I've been struggling to find a decent RTP stack implementation for Java. JMF or FMJ are not options here as I don't want all the bells and whistles of codecs and audio/video capture; I just need to create RTP streams, dump data in them and read data from them.
I've been using jlibrtp https://wiki.cs.columbia.edu:8443/display/~hg...
Hi,
I'm writing a recursive flood-fill algorithm to find connected components in an image, my code compiles and runs well with MSVC 2008 compiler; but the mingw-compiled binary crashed at runtime.
After I converted the algorithm to non-recursive with std::stack, everything goes well.
But what if I must use recursive algorithm in some...
I'm trying to call io_submit using python ctypes.
The code I'm writing is supposed to work on both 32 and 64-bit Intel/AMD architectures, but here I'll focus on 64 bits.
I have defined the following:
def PADDED64(type, name1, name2):
return [(name1, type), (name2, type)]
def PADDEDptr64(type, name1, name2):
return [(name1, ty...
Using a temp variable to store max value does not work for pop operations.
...
So modern languages like perl, java, and C pass data around (function parameter for example) via pointers (if written correctly that is), so on the stack when you pass a variable in, the address of that variable is written. I was looking into old versions of fortran, before pointers, and was wondering: How was data passed around before p...
Hello! I need an algorithm that introduces data like a stack, so when I scan the structure I can read them in the same sequence as they were introduced, for sequential access. Also these values are stored in buckets, like a hashtable, so I can fragment the whole structure for disk storage and have fast random access.
Is there an algorit...
Hi there,
This is my first pathetic attempt at C++. I did an array based stack in C++ and the destructor is throwing out some memory dump. I can't figure out what went wrong.
#include <stdio.h>
#include <iostream>
#include <exception>
using namespace std;
class FullStackException : public exception {
virtual const char* what() ...
I have two applications App-1 & App-2. App-2 has a button which will start App-1.
The need is to behave like the following:-
User launches App-1 (using launcher) & activities A, B & C are started & activity C is at the top of the activity stack.
Please note that entry point of App-1 is activity A.
User presses home key.
User then lau...
I'm wondering if it's possible to determine if a given address is on the stack or in the heap. I'd like this because a reference counting system we use has a flaw that if a smart pointer is somehow pointed at an object on the stack, bad things can happen. If I had this functionality, I could use it to detect this error condition early an...
In Foxpro how to get Call stack info for logging.(not using the debugger ui, but in code at runtime)
...
I just know that the non-primitives (the objects) go on the heap, and methods go on the stack, but what about the primitive variables?
--update
Based on the answers, I could say the heap can have a new stack and heap for a given object? Given that the object will have primitive and reference variables..?
...
I have a basic java server app that has 100 worker threads that do simple HEAD requests on urls. I'm using HttpClient 4.x for this.
A few minutes into the run my program just freezes for a couple minutes and I cannot figure out why. Check out the screen shot of what visual vm monitor reports. You can see it flatline. During this time I...
It's a little difficult to explain the offending piece of code, as there seems to be some degree of stack corruption, and all the code's pretty linked together (it's a game). If you're looking for a headache and some debugging, please check out the segfault branch on
git://github.com/RobotGymnast/Gingerbread.git and see if you can find ...
I'm writing an iPhone app, and I'm surprised that there seem to be no NSQueue or NSStack classes in Apple's Foundation Framework. I see that it would be quite easy to roll my own, starting with an NSMutableArray, so I'll do that unless I've missed something. Have I missed something?
...
I am trying to understand the assembly level code for a simple C program by inspecting it with gdb's disassembler.
Following is the C code:
#include <stdio.h>
void function(int a, int b, int c) {
char buffer1[5];
char buffer2[10];
}
void main() {
function(1,2,3);
}
Following is the disassembly code for both main and functio...
Hi all,
Since enum in C# are on the stack, I was wondering where enum, in Java, where created. On the stack? On the heap? In some mysterious other place?
Enumeration in C# are more primitive than those in Java, this might explain why they are created on the stack...
Where are they? I can't find them!
Thanks
...