Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any plans for a migration guide? #402

Closed
JCMais opened this issue Aug 5, 2015 · 13 comments
Closed

Any plans for a migration guide? #402

JCMais opened this issue Aug 5, 2015 · 13 comments

Comments

@JCMais
Copy link

JCMais commented Aug 5, 2015

Updating from NaN 1.x to 2.x is getting more harder than I thought.

@winfinit
Copy link

winfinit commented Aug 6, 2015

converted examples in node-addon-examples may make it a bit easier (pull request is pending, but you can see nan_2.x and nan_1.x here: https://github.com/winfinit/node-addon-examples)

also what helped me a lot is to look through https://github.com/nodejs/nan/tree/master/test

@kkoopa
Copy link
Collaborator

kkoopa commented Aug 9, 2015

@ivan
Copy link

ivan commented Aug 10, 2015

The converter script in #376 (comment) was very helpful for me

@mscdex
Copy link
Contributor

mscdex commented Aug 13, 2015

+1

@eljefedelrodeodeljefe
Copy link
Contributor

Good hint @winfinit . Found everything I needed in the test directory.

@lovell
Copy link
Contributor

lovell commented Aug 24, 2015

The biggest gotcha I've run into between nan v1 and v2 is a change to the Buffer creation methods where ownership of the underlying data is transferred.

In nan v1, the "take ownership" method is NanBufferUse which results in delete[] being called on the data during GC.

In nan v2, the "take ownership" method is Nan::NewBuffer which results in free() being called.

@JCMais
Copy link
Author

JCMais commented Aug 24, 2015

@lovell I had a bunch of memory corruption because of this exact change. Took awhile to figure it out.

lovell added a commit to lovell/nan that referenced this issue Aug 24, 2015
Should hopefully ease v2 upgrades - see nodejs#402
lovell added a commit to lovell/nan that referenced this issue Aug 24, 2015
Should hopefully ease v2 upgrades - see nodejs#402
kkoopa pushed a commit that referenced this issue Aug 25, 2015
Should hopefully ease v2 upgrades - see #402
@mathiask88
Copy link
Contributor

So if I use new for memory allocation then I need to use BufferCopy and cannot use the allocated memory block because it is removed with free()?

@kkoopa
Copy link
Collaborator

kkoopa commented Aug 27, 2015

Supply a FreeCallback that calls delete.

@mathiask88
Copy link
Contributor

@kkoopa Ah thanks, I read over that one. Is there a nan wrapper for node::smalloc::FreeCallback and node::Buffer::FreeCallback callback? And what is the hint argument?

@kkoopa
Copy link
Collaborator

kkoopa commented Aug 27, 2015

https://github.com/nodejs/nan/blob/master/nan.h#L1218
The hint argument is user data.

@rvagg
Copy link
Member

rvagg commented Sep 25, 2015

@JCMais
Copy link
Author

JCMais commented Sep 25, 2015

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants