#include <iostream>
#include "moz.h"
#include "nsexception.h"

using namespace std;

class Foo {
  nsresult test(Foo **outparam);
  Foo *pointer;
};
// for the exception rewrite
// should override the new operator to throw
// moz-friendly nsexceptions instead of std::bad_alloc
nsresult Foo::test(Foo **outparam) {
    int *buf = new int;
    //thrower should nuke this code
    if (!buf)
      return NS_ERROR_OUT_OF_MEMORY;
    delete buf;
    // same goes for attributes
    if (!pointer)
      return NS_ERROR_OUT_OF_MEMORY;
    
    *outparam = new Foo();
    if (!*outparam)
      return NS_ERROR_OUT_OF_MEMORY;

    if (*outparam == nsnull)
      return NS_ERROR_OUT_OF_MEMORY;

    return NS_OK;
}

int main(int argc, char **argv) {

  return 0;
}
