charto / nbind

:sparkles: Magical headers that make your C++ library accessible from JavaScript :rocket:
MIT License
1.98k stars 119 forks source link

how to return same reference using c++ pointer ? and returning reference maybe memory leak ? #121

Open tommyZZM opened 6 years ago

tommyZZM commented 6 years ago
// c++
class SomeThing {

  SomeThing() {};

  ~SomeThing() {};

  SomeThing* getRef() {
    return this;
  }

}

NBIND_CLASS(SomeThing) {
  method(getRef);
}
// javascript
const a = new SomeThing();
console.log(a.getRef() === a.getRef()); // false

Will this make memory leak while calling the.getRef() method ?