Search Results

Search found 252786 results on 10112 pages for 'stack'.

Page 22/10112 | < Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >

  • Unable to locate the Bug

    - by tzenes
    I was recently on The Daily WTF when I came across this old post. In it the author mentions that one of the programmers changed this code: int main (int argc, char **argv) { int x; char data_string[15]; ... x = 2; strcpy(data_string,"data data data"); ... } To this code: int main (int argc, char **argv) { int x = 2; char data_string[15] = "data data data"; ... } The author goes on to mention: [the coder] changed every single variable to be initiated on the stack For the life of me I cannot see how this change could be harmful, and I am worried that it is a lapse in my C knowledge. What is the WTF?

    Read the article

  • Primary reasons why programming language runtimes use stacks?

    - by manuel aldana
    Many programming language runtime environments use stacks as their primary storage structure (e.g. see JVM bytecode to runtime example). Quickly recalling I see following advantages: Simple structure (pop/push), trivial to implement Most processors are anyway optimized for stack operations, so it is very fast Less problems with memory fragmentation, it is always about moving memory-pointer up and down for allocation and freeing complete blocks of memory by resetting the pointer to the last entry offset. Is the list complete or did I miss something? Are there programming language runtime environments which are not using stacks for storage at all?

    Read the article

  • C++ memory management of reference types

    - by Russel
    Hello, I'm still a fairly novice programmer and I have a question about c++ memory management with refence types. First of all, my understanding of reference types: A pointer is put on the stack and the actual data that the pointer points to is created and placed on the heap. Standard arrays and user defined classes are refence types. Is this correct? Second, my main question is do c and c++'s memory management mechanisms (malloc, free and new, delete) always handle this properly and free the memory that a class or array is pointing to? Does everything still work if those pointers get reassigned somehow to other objects of the same size/type on the heap? What if a class has a pointer member that points to another object? I am assuming that delete/freeing the class object doesn't free what it's member pointer points to, is that correct? Thanks all! -R

    Read the article

  • Are tags considered requirements? [closed]

    - by krunk
    I'm new to stack overflow, made a few responses. I responded to a question that was something like: "I need to do X, I found a sed one liner that almost does it, but not quite" And was tagged 'sed'. I assumed the user just wanted a solution and tagged it with sed because it was a possible answer. So I suggested an alternate way using another tool that was more concise and didn't involve regex (another one-liner). I received a down vote for not meeting the requirement of the user. Since I'd like to make sure I conform to good forum etiquette, my question is: Are tags considered hard requirements that should limit the scope of responses? (within reason of course, a .NET question with a .NET tag obviously shouldn't receive a ruby answer).

    Read the article

  • how does memory stacks work in javascript

    - by user227353
    When we have code like: function a(){ var x =0; this.add=function(){ alert(x++); } } var test = new a(); test.add(); // alert 0 test.add(); // alert 1 test.add(); // alert 2 How does this work? Doesn't that the value of 'x' in a() should be 'gone' as soon as test = new a() is complete? The stack contains x should also be gone as well, right? Or, does javascript always keep all the stacks ever created in case they will be referenced in future? But that wouldn't be nice, would it...?

    Read the article

  • Initialization of array on heap

    - by Radek Šimko
    How do i manually initiate values in array on heap? If the array is local variable (in stack), it can be done very elegant and easy way, like this: int myArray[3] = {1,2,3}; Unfortunately, following code int * myArray = new int[3]; myArray = {1,2,3}; outputs an error by compiling error: expected primary-expression before ‘{’ token error: expected `;' before ‘{’ token Do i have to use cycle, or not-so-much-elegant way like this? myArray[0] = 1; myArray[1] = 2; myArray[2] = 3;

    Read the article

  • Stacking Dialogs in Android

    - by ChaimKut
    Is there a way to control the relative stacking of Dialogs produced by your own Activity? For instance, there are some more important Dialogs which I would like to ensure are on top and if another Dialog wants to pop up I would want it to pop under the important Dialogs. Example: I want to present to the user an important dialog, Dialog A. The activity realizes that there is a dialog, Dialog B, of lesser importance to display to the user. Is it possible to specify Dialog B to be under Dialog A so that when Dialog A is cleared, Dialog B will be seen by the user? I know that the onDismiss interface exists, but this necessarily ties Dialog A and Dialog B together. I want the Dialogs to be independent and would prefer to use a higher level abstraction like the window stack responsible for ordering the Dialogs.

    Read the article

  • Are destructors of automatic objects invoked when terminate is called?

    - by nbolton
    I'm pondering a question on Brainbench. I actually realised that I could answer my question easily by compiling the code, but it's an interesting question nonetheless, so I'll ask the question anyway and answer it myself shortly. Take a look at this snippet: The question considers what happens when we throw from a destructor (which causes terminate() to be called). It's become clear to me by asking the question that the memory is indeed freed and the destructor is called, but, is this before or after throw is called from foo? Perhaps the issue here is that throw is used while the stack is unwinding that is the problem... Actually this is slightly confusing.

    Read the article

  • why does it use the movl instead of push ?!

    - by user554403
    hi all. pay attention to this code : #include <stdio.h> void a(int a, int b, int c) { char buffer1[5]; char buffer2[10]; } int main() { a(1,2,3); } after that : gcc -S a.c that command shows our source code in assembly. now we can see in the main function, we never use "push" command to push the arguments of the a function into the stack. and it used "movel" instead of that main: pushl %ebp movl %esp, %ebp andl $-16, %esp subl $16, %esp movl $3, 8(%esp) movl $2, 4(%esp) movl $1, (%esp) call a leave why does it happen? what's difference between them?

    Read the article

  • Trying to convert simple midlet application to Android application but running into problems.

    - by chobo2
    Hi I am trying to do some threading in Android so I took an old threading assignment I had done fora midlet and took out the midlet code and replaced it with android code(such as textview). package com.assignment1; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class Threading extends Activity { private TextView tortose; private TextView hare; private Thread hareThread; private Thread torotoseThread; private int num = 0; private int num2 = 0; public Threading() { } /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); tortose = (TextView) findViewById(R.id.TextView01); hare = (TextView) findViewById(R.id.TextView02); Hare newHare = new Hare(); hareThread = new Thread(newHare); hareThread.start(); Torotose newTortose = new Torotose(); torotoseThread = new Thread(newTortose); torotoseThread.start(); //updateDisplay(); } private synchronized void check(int value1, int value2) { if((value1-value2) >= 10) { try { wait(); } catch(Exception ex) { System.out.println(ex); } } } private synchronized void getGoing(int value1, int value2) { if((value1-value2) == 0) { try { notify(); } catch(Exception ex) { System.out.println(ex); } } } private class Hare extends Thread { public void run() { while(true) { num++; hare.setText(Integer.toString(num)); check(num, num2); try { // are threads different in andriod apps? Thread.sleep(100); // hareThread.sleep(100); } catch(Exception ex) { System.out.println(ex); } } } } private class Torotose extends Thread { public void run() { while(true) { num2++; tortose.setText(Integer.toString(num2)); getGoing(num,num2); try { Thread.sleep(200); //torotoseThread.sleep(200); } catch(Exception ex) { System.out.println(ex); } } } } } First it wanted me to change my threads to like static threads.So is this just how Android does it? Next when I run this code it just crashes with some unexpected error. I am not sure what the error is but when I try to debug it and goes to like to create a new "hare" object it shows me this. // Compiled from ClassLoader.java (version 1.5 : 49.0, super bit) public abstract class java.lang.ClassLoader { // Method descriptor #8 ()V // Stack: 3, Locals: 1 protected ClassLoader(); 0 aload_0 [this] 1 invokespecial java.lang.Object() [1] 4 new java.lang.RuntimeException [2] 7 dup 8 ldc <String "Stub!"> [3] 10 invokespecial java.lang.RuntimeException(java.lang.String) [4] 13 athrow Line numbers: [pc: 0, line: 4] Local variable table: [pc: 0, pc: 14] local: this index: 0 type: java.lang.ClassLoader // Method descriptor #14 (Ljava/lang/ClassLoader;)V // Stack: 3, Locals: 2 protected ClassLoader(java.lang.ClassLoader parentLoader); 0 aload_0 [this] 1 invokespecial java.lang.Object() [1] 4 new java.lang.RuntimeException [2] 7 dup 8 ldc <String "Stub!"> [3] 10 invokespecial java.lang.RuntimeException(java.lang.String) [4] 13 athrow Line numbers: [pc: 0, line: 5] Local variable table: [pc: 0, pc: 14] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 14] local: parentLoader index: 1 type: java.lang.ClassLoader // Method descriptor #17 ()Ljava/lang/ClassLoader; // Stack: 3, Locals: 0 public static java.lang.ClassLoader getSystemClassLoader(); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 6] // Method descriptor #19 (Ljava/lang/String;)Ljava/net/URL; // Stack: 3, Locals: 1 public static java.net.URL getSystemResource(java.lang.String resName); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 7] Local variable table: [pc: 0, pc: 10] local: resName index: 0 type: java.lang.String // Method descriptor #23 (Ljava/lang/String;)Ljava/util/Enumeration; // Signature: (Ljava/lang/String;)Ljava/util/Enumeration<Ljava/net/URL;>; // Stack: 3, Locals: 1 public static java.util.Enumeration getSystemResources(java.lang.String resName) throws java.io.IOException; 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 8] Local variable table: [pc: 0, pc: 10] local: resName index: 0 type: java.lang.String // Method descriptor #29 (Ljava/lang/String;)Ljava/io/InputStream; // Stack: 3, Locals: 1 public static java.io.InputStream getSystemResourceAsStream(java.lang.String resName); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 9] Local variable table: [pc: 0, pc: 10] local: resName index: 0 type: java.lang.String // Method descriptor #31 ([BII)Ljava/lang/Class; // Signature: ([BII)Ljava/lang/Class<*>; // Stack: 3, Locals: 4 protected final java.lang.Class defineClass(byte[] classRep, int offset, int length) throws java.lang.ClassFormatError; 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 10] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: classRep index: 1 type: byte[] [pc: 0, pc: 10] local: offset index: 2 type: int [pc: 0, pc: 10] local: length index: 3 type: int // Method descriptor #39 (Ljava/lang/String;[BII)Ljava/lang/Class; // Signature: (Ljava/lang/String;[BII)Ljava/lang/Class<*>; // Stack: 3, Locals: 5 protected final java.lang.Class defineClass(java.lang.String className, byte[] classRep, int offset, int length) throws java.lang.ClassFormatError; 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 11] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: className index: 1 type: java.lang.String [pc: 0, pc: 10] local: classRep index: 2 type: byte[] [pc: 0, pc: 10] local: offset index: 3 type: int [pc: 0, pc: 10] local: length index: 4 type: int // Method descriptor #42 (Ljava/lang/String;[BIILjava/security/ProtectionDomain;)Ljava/lang/Class; // Signature: (Ljava/lang/String;[BIILjava/security/ProtectionDomain;)Ljava/lang/Class<*>; // Stack: 3, Locals: 6 protected final java.lang.Class defineClass(java.lang.String className, byte[] classRep, int offset, int length, java.security.ProtectionDomain protectionDomain) throws java.lang.ClassFormatError; 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 12] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: className index: 1 type: java.lang.String [pc: 0, pc: 10] local: classRep index: 2 type: byte[] [pc: 0, pc: 10] local: offset index: 3 type: int [pc: 0, pc: 10] local: length index: 4 type: int [pc: 0, pc: 10] local: protectionDomain index: 5 type: java.security.ProtectionDomain // Method descriptor #46 (Ljava/lang/String;Ljava/nio/ByteBuffer;Ljava/security/ProtectionDomain;)Ljava/lang/Class; // Signature: (Ljava/lang/String;Ljava/nio/ByteBuffer;Ljava/security/ProtectionDomain;)Ljava/lang/Class<*>; // Stack: 3, Locals: 4 protected final java.lang.Class defineClass(java.lang.String name, java.nio.ByteBuffer b, java.security.ProtectionDomain protectionDomain) throws java.lang.ClassFormatError; 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 13] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: name index: 1 type: java.lang.String [pc: 0, pc: 10] local: b index: 2 type: java.nio.ByteBuffer [pc: 0, pc: 10] local: protectionDomain index: 3 type: java.security.ProtectionDomain // Method descriptor #52 (Ljava/lang/String;)Ljava/lang/Class; // Signature: (Ljava/lang/String;)Ljava/lang/Class<*>; // Stack: 3, Locals: 2 protected java.lang.Class findClass(java.lang.String className) throws java.lang.ClassNotFoundException; 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 14] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: className index: 1 type: java.lang.String // Method descriptor #52 (Ljava/lang/String;)Ljava/lang/Class; // Signature: (Ljava/lang/String;)Ljava/lang/Class<*>; // Stack: 3, Locals: 2 protected final java.lang.Class findLoadedClass(java.lang.String className); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 15] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: className index: 1 type: java.lang.String // Method descriptor #52 (Ljava/lang/String;)Ljava/lang/Class; // Signature: (Ljava/lang/String;)Ljava/lang/Class<*>; // Stack: 3, Locals: 2 protected final java.lang.Class findSystemClass(java.lang.String className) throws java.lang.ClassNotFoundException; 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 16] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: className index: 1 type: java.lang.String // Method descriptor #17 ()Ljava/lang/ClassLoader; // Stack: 3, Locals: 1 public final java.lang.ClassLoader getParent(); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 17] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader // Method descriptor #19 (Ljava/lang/String;)Ljava/net/URL; // Stack: 3, Locals: 2 public java.net.URL getResource(java.lang.String resName); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 18] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: resName index: 1 type: java.lang.String // Method descriptor #23 (Ljava/lang/String;)Ljava/util/Enumeration; // Signature: (Ljava/lang/String;)Ljava/util/Enumeration<Ljava/net/URL;>; // Stack: 3, Locals: 2 public java.util.Enumeration getResources(java.lang.String resName) throws java.io.IOException; 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 19] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: resName index: 1 type: java.lang.String // Method descriptor #29 (Ljava/lang/String;)Ljava/io/InputStream; // Stack: 3, Locals: 2 public java.io.InputStream getResourceAsStream(java.lang.String resName); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 20] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: resName index: 1 type: java.lang.String // Method descriptor #52 (Ljava/lang/String;)Ljava/lang/Class; // Signature: (Ljava/lang/String;)Ljava/lang/Class<*>; // Stack: 3, Locals: 2 public java.lang.Class loadClass(java.lang.String className) throws java.lang.ClassNotFoundException; 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 21] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: className index: 1 type: java.lang.String // Method descriptor #62 (Ljava/lang/String;Z)Ljava/lang/Class; // Signature: (Ljava/lang/String;Z)Ljava/lang/Class<*>; // Stack: 3, Locals: 3 protected java.lang.Class loadClass(java.lang.String className, boolean resolve) throws java.lang.ClassNotFoundException; 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 22] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: className index: 1 type: java.lang.String [pc: 0, pc: 10] local: resolve index: 2 type: boolean // Method descriptor #67 (Ljava/lang/Class;)V // Signature: (Ljava/lang/Class<*>;)V // Stack: 3, Locals: 2 protected final void resolveClass(java.lang.Class clazz); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 23] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: clazz index: 1 type: java.lang.Class Local variable type table: [pc: 0, pc: 10] local: clazz index: 1 type: java.lang.Class<?> // Method descriptor #19 (Ljava/lang/String;)Ljava/net/URL; // Stack: 3, Locals: 2 protected java.net.URL findResource(java.lang.String resName); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 24] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: resName index: 1 type: java.lang.String // Method descriptor #23 (Ljava/lang/String;)Ljava/util/Enumeration; // Signature: (Ljava/lang/String;)Ljava/util/Enumeration<Ljava/net/URL;>; // Stack: 3, Locals: 2 protected java.util.Enumeration findResources(java.lang.String resName) throws java.io.IOException; 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 25] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: resName index: 1 type: java.lang.String // Method descriptor #76 (Ljava/lang/String;)Ljava/lang/String; // Stack: 3, Locals: 2 protected java.lang.String findLibrary(java.lang.String libName); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 26] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: libName index: 1 type: java.lang.String // Method descriptor #79 (Ljava/lang/String;)Ljava/lang/Package; // Stack: 3, Locals: 2 protected java.lang.Package getPackage(java.lang.String name); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 27] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: name index: 1 type: java.lang.String // Method descriptor #81 ()[Ljava/lang/Package; // Stack: 3, Locals: 1 protected java.lang.Package[] getPackages(); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 28] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader // Method descriptor #83 (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/net/URL;)Ljava/lang/Package; // Stack: 3, Locals: 9 protected java.lang.Package definePackage(java.lang.String name, java.lang.String specTitle, java.lang.String specVersion, java.lang.String specVendor, java.lang.String implTitle, java.lang.String implVersion, java.lang.String implVendor, java.net.URL sealBase) throws java.lang.IllegalArgumentException; 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 29] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: name index: 1 type: java.lang.String [pc: 0, pc: 10] local: specTitle index: 2 type: java.lang.String [pc: 0, pc: 10] local: specVersion index: 3 type: java.lang.String [pc: 0, pc: 10] local: specVendor index: 4 type: java.lang.String [pc: 0, pc: 10] local: implTitle index: 5 type: java.lang.String [pc: 0, pc: 10] local: implVersion index: 6 type: java.lang.String [pc: 0, pc: 10] local: implVendor index: 7 type: java.lang.String [pc: 0, pc: 10] local: sealBase index: 8 type: java.net.URL // Method descriptor #94 (Ljava/lang/Class;[Ljava/lang/Object;)V // Signature: (Ljava/lang/Class<*>;[Ljava/lang/Object;)V // Stack: 3, Locals: 3 protected final void setSigners(java.lang.Class c, java.lang.Object[] signers); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 30] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: c index: 1 type: java.lang.Class [pc: 0, pc: 10] local: signers index: 2 type: java.lang.Object[] Local variable type table: [pc: 0, pc: 10] local: c index: 1 type: java.lang.Class<?> // Method descriptor #100 (Ljava/lang/String;Z)V // Stack: 3, Locals: 3 public void setClassAssertionStatus(java.lang.String cname, boolean enable); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 31] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: cname index: 1 type: java.lang.String [pc: 0, pc: 10] local: enable index: 2 type: boolean // Method descriptor #100 (Ljava/lang/String;Z)V // Stack: 3, Locals: 3 public void setPackageAssertionStatus(java.lang.String pname, boolean enable); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 32] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: pname index: 1 type: java.lang.String [pc: 0, pc: 10] local: enable index: 2 type: boolean // Method descriptor #106 (Z)V // Stack: 3, Locals: 2 public void setDefaultAssertionStatus(boolean enable); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 33] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader [pc: 0, pc: 10] local: enable index: 1 type: boolean // Method descriptor #8 ()V // Stack: 3, Locals: 1 public void clearAssertionStatus(); 0 new java.lang.RuntimeException [2] 3 dup 4 ldc <String "Stub!"> [3] 6 invokespecial java.lang.RuntimeException(java.lang.String) [4] 9 athrow Line numbers: [pc: 0, line: 34] Local variable table: [pc: 0, pc: 10] local: this index: 0 type: java.lang.ClassLoader } So I am not sure where I went wrong. Thanks

    Read the article

  • Trying to calculate the 10001st prime number in Java.

    - by user247679
    Greetings. I am doing Problem 7 from Project Euler. What I am supposed to do is calculate the 10001st prime number. (A prime number being a number that is only divisible by itself and one.) Here is my current program: public class Problem7 { public static void main(String args []){ long numberOfPrimes = 0; long number = 2; while (numberOfPrimes < 10001){ if(isPrime(number)){ numberOfPrimes++; } number++; } System.out.println("10001st prime: "+ number); } public static boolean isPrime(long N) { if (N <= 1) return false; else return Prime(N,N-1); } public static boolean Prime(long X,long Y) { if (Y == 1) return true; else if (X % Y == 0) return false; else return Prime(X, Y-1); } } It works okay with finding, say the 100th prime number, but when I enter very large numbers such as 10001 it causes a stack overflow. Does anyone know of a way to fix this? Thanks for reading my problem!

    Read the article

  • Processing command-line arguments in prefix notation in Python

    - by ejm
    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 notation". In the Bourne shell I would do something like the following: while test -n "$1" do if test "$1" = '-o' then option="$2" shift 2 fi # Work with $1 (the argument) and $option (the option) # ... shift done Looking around at the Bash tutorials, etc. this seems to be the accepted idiom, so I'm guessing Bash is optimized to work with command-line arguments this way. Trying to implement this pattern in Python, my first guess was to use pop(), as this is basically a stack operation. But I'm guessing this won't work as well on Python because the list of arguments in sys.argv is in the wrong order and would have to be processed like a queue (i.e. pop from the left). I've read that lists are not optimized for use as queues in Python. So, my ideas are: convert argv to a collections.deque and use popleft(), reverse argv using reverse() and use pop(), or maybe just work with the int list indices themselves. Does anyone know of a better way to do this, otherwise which of my ideas would be best-practise in Python?

    Read the article

  • Dojo StackContainer children are not resizing on browser maximise/restore

    - by Andy
    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 BorderContainer. The problem I have is that the StackContainer children (BorderContainer 2 and 3) do not get resized to the StackContainer's contentBox. Is there something special you have to do to force a resize of StackContainer children? I have tried calling StackContainer1.resize() but this makes no difference. Thanks in advance. Additional information: Thanks for the reply peller. The widget hierachy that contains the StackContainer is actually a custom widget, so the StackContainer is not actually in a BorderContainer directly, but has its height and width explicitly set to 100%. This works and the StackContainer is resized correctly on browser maximise. The direct children of the stackcontainer are BorderContainers and it is these BorderContainers that do not get resized when the StackContainer is resized. One point to note is that when the StackContainer is created in markup, the stackcontainer children are empty divs. These divs are then used as placeholders for custom widget creation, e.g. var widget = new com.company.widget(params, placeholderDiv); where placeholderDiv is a direct child of the StackContainer in markup. Should I be adding the programatically created 'widget' to the stackcontainer using addChild instead?

    Read the article

  • Calling cdecl Functions That Have Different Number of Arguments

    - by KlaxSmashing
    I have functions that I wish to call based on some input. Each function has different number of arguments. In other words, if (strcmp(str, "funcA") == 0) funcA(a, b, c); else if (strcmp(str, "funcB") == 0) funcB(d); else if (strcmp(str, "funcC") == 0) funcC(f, g); This is a bit bulky and hard to maintain. Ideally, these are variadic functions (e.g., printf-style) and can use varargs. But they are not. So exploiting the cdecl calling convention, I am stuffing the stack via a struct full of parameters. I'm wondering if there's a better way to do it. Note that this is strictly for in-house (e.g., simple tools, unit tests, etc.) and will not be used for any production code that might be subjected to malicious attacks. Example: #include <stdio.h> typedef struct __params { unsigned char* a; unsigned char* b; unsigned char* c; } params; int funcA(int a, int b) { printf("a = %d, b = %d\n", a, b); return a; } int funcB(int a, int b, const char* c) { printf("a = %d, b = %d, c = %s\n", a, b, c); return b; } int funcC(int* a) { printf("a = %d\n", *a); *a *= 2; return 0; } typedef int (*f)(params); int main(int argc, char**argv) { int val; int tmp; params myParams; f myFuncA = (f)funcA; f myFuncB = (f)funcB; f myFuncC = (f)funcC; myParams.a = (unsigned char*)100; myParams.b = (unsigned char*)200; val = myFuncA(myParams); printf("val = %d\n", val); myParams.c = (unsigned char*)"This is a test"; val = myFuncB(myParams); printf("val = %d\n", val); tmp = 300; myParams.a = (unsigned char*)&tmp; val = myFuncC(myParams); printf("a = %d, val = %d\n", tmp, val); return 0; } Output: gcc -o func func.c ./func a = 100, b = 200 val = 100 a = 100, b = 200, c = This is a test val = 200 a = 300 a = 600, val = 0

    Read the article

  • Copy method optimization in compilers

    - by Dženan
    Hi All! I have the following code: void Stack::operator =(Stack &rhs) { //do the actual copying } Stack::Stack(Stack &rhs) //copy-constructor { top=NULL; //initialize this as an empty stack (which it is) *this=rhs; //invoke assignment operator } Stack& Stack::CopyStack() { return *this; //this statement will invoke copy contructor } It is being used like this: unsigned Stack::count() { unsigned c=0; Stack copy=CopyStack(); while (!copy.empty()) { copy.pop(); c++; } return c; } Removing reference symbol from declaration of CopyStack (returning a copy instead of reference) makes no difference in visual studio 2008 (with respect to number of times copying is invoked). I guess it gets optimized away - normally it should first make a copy for the return value, then call assignment operator once more to assign it to variable sc. What is your experience with this sort of optimization in different compilers? Regards, Dženan

    Read the article

  • Why do so few large websites run a Microsoft stack?

    - by realworldcoder
    Off the top of my head, I can think of a handful of large sites which utilize the Microsoft stack Microsoft.com Dell MySpace PlentyOfFish StackOverflow Hotmail, Bing, WindowsLive However, based on observation, nearly all of the top 500 sites seem to be running other platforms.What are the main reasons there's so little market penetration? Cost? Technology Limitations? Does Microsoft cater to corporate / intranet environments more then public websites? I'm not looking for market share, but rather large scale adoption of the MS stack.

    Read the article

  • How to know what dll or services taskhost.exe is hosting?

    - by tigrou
    I have recently discover a new process in the task manager : taskhost.exe (maybe it was there before but i did not notice it) As the name implies, it seems to be used for running dll in background (like rundll32.exe). Is there a way to know which dll / services this process is hosting ? i would like to know for which purpose it is used and if there is some malware or not. I know it is possible to see which services svchost.exe process is hosting using process explorer utility. I have checked taskhost.exe threads and their stacks using process explorer, here is what i get : So it seems it is used for sound (winmm + playsndsrv). But there is also other things for which very few information is provided (ex : thread 1456, taskhost.exe as start address and nothing relevant can be found in stack (same for 1464, 2272 and so). So maybe it is not the right way to do.

    Read the article

  • Is there some advantage to filling a stack with nils and interpreting the "top" as the last non-nil value?

    - by dwilbank
    While working on a rubymonk exercise, I am asked to implement a stack with a hard size limit. It should return 'nil' if I try to push too many values, or if I try to pop an empty stack. My solution is below, followed by their solution. Mine passes every test I can give it in my IDE, while it fails rubymonk's test. But that isn't my question. Question is, why did they choose to fill the stack with nils instead of letting it shrink and grow like it does in my version? It just makes their code more complex. Here's my solution: class Stack def initialize(size) @max = size @store = Array.new end def pop empty? ? nil : @store.pop end def push(element) return nil if full? @store.push(element) end def size @store.size end def look @store.last end private def full? @store.size == @max end def empty? @store.size == 0 end end and here is the accepted answer class Stack def initialize(size) @size = size @store = Array.new(@size) @top = -1 end def pop if empty? nil else popped = @store[@top] @store[@top] = nil @top = @top.pred popped end end def push(element) if full? or element.nil? nil else @top = @top.succ @store[@top] = element self end end def size @size end def look @store[@top] end private def full? @top == (@size - 1) end def empty? @top == -1 end end

    Read the article

  • How to move value from the stack to ST(0)?

    - by George Edison
    I am having trouble believing the following code is the most efficient way to move a value from the stack to ST(0): .data var dd 4.2 tmp dd ? .code mov EAX, var push EAX ; top of stack now contains a value ; move it to ST(0) pop EAX mov tmp, EAX fld tmp Is the temporary variable really necessary? Further, is there an easier way to get a value from the stack to ST(0)?

    Read the article

  • Does Ruby have a special stack for returning a value?

    - by prosseek
    The following Ruby code def a(b,c) b+c end is the same as follows with Python def a(b,c): return b+c It looks like that ruby has the special stack that stores the final evaluation result and returns the value when a function is called. If so, what's the name of the stack, and how can I get that stack? If not, how does the Ruby code work without returning something?

    Read the article

  • Does Ruby have a special stack for return value?

    - by prosseek
    The following Ruby code def a(b,c) b+c end is the same as follows with Python def a(b,c): return b+c It looks like that ruby has the special stack that stores the final evaluation result and returns the value when a function is called. If so, what's the name of the stack, and how can I get that stack? If not, how does the Ruby code work without returning something?

    Read the article

  • Is there a utility to visualise / isolate and watch application calls

    - by MyStream
    Note: I'm not sure what to search for so guidance on that may be just as valuable as an answer. I'm looking for a way to visually compare activity of two applications (in this case a webserver with php communicating with the system or mysql or network devices, etc) such that I can compare the performance at a glance. I know there are tools to generate data dumps from benchmarks for apache and some available for php for tracing that you can dump and analyse but what I'm looking for is something that can report performance metrics visually from data on calls (what called what, how long did it take, how much memory did it consume, how can that be represented visually in a call stack) and present it graphically as if it were a topology or layered visual with different elements of system calls occupying different layers. A typical visual may consist of (e.g. using swim diagrams as just one analogy): Network (details here relevant to network diagnostics) | ^ back out v | Linux (details here related to firewall/routing diagnostics) ^ back to network | | V ^ back to system Apache (details here related to web request) | | ^ response to V | apache PHP (etc) PHP---------->other accesses to php files/resources----- | ^ v | MySQL (total time) MySQL | ^ V | Each call listed + time + tables hit/record returned My aim would be to be able to 'inspect' a request/range of requests over a period of time to see what constituted the activity at that point in time and trace it from beginning to end as a diagnostic tool. Is there any such work in this direction? I realise it would be intensive on the server, but the intention is to benchmark and analyse processes against each other for both educational and professional reasons and a visual aid is a great eye-opener compared to raw statistics or dozens of discrete activity vs time graphs. It's hard to show the full cycle. Any pointers welcome. Thanks! FROM COMMENTS: > XHProf in conjunction with other programs such as Perconna toolkit > (percona.com/doc/percona-toolkit/2.0/pt-pmp.html) for mySQL run apache > with httpd -X & (Single threaded debug mode and background) then > attach with strace -> kcache grind

    Read the article

  • How to reference or connect a variable to another class without stack overflow?

    - by SystemNetworks
    I really need to re-arrange all my functions. I created a class. All my var, booleans, int, doubles and other things. I created every new variable so they can reference it and so they don't have an error. If your asking why I never just reference my main class vars to my sub-class becuase it will give me stack overflow! When in my main class i link my sub-class. subClass s = new subClass(); Then I reference my fake variable to my real variable for example: This is my sub-class variable(I call it fake) public int x = 0; In my main class, I put it like this: s.x = x; The problem is, it does not work! Maybe this is not the right place but I cant ask any questions on stack overflow because they banned me. If I connect my main class and connect my sub-class it will give me stack overflow. How do I stop it?

    Read the article

< Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >