Sign in to follow this  

Passing NULL to

This topic is 2847 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've seen that D3DXVECTOR3 * D3DXVec3Normalize(D3DXVECTOR3 * pOut, CONST D3DXVECTOR3 * pV); and similar functions returns "the same value returned in the pOut parameter. In this way, the D3DXVec3Normalize function can be used as a parameter for another function." (from documentation). Does this mean that I'm allowed to pass a NULL pointer as pOut? It feels a little bad to do it, but sure would be convenient... :) Are there any official guidelines for using such functions as parameters for other functions, as indicated by the documentation?

Share this post


Link to post
Share on other sites
I'm almost positive that you would not be allowed to do that. The D3DXVec3Normalize function would try to dereference a NULL pointer, thus creating a segmentation fault. Now maybe I am incorrect, and thet actually coded that functionality into the function, but it could all be cleared up by a simple test on your end.

[Edited by - Halifax2 on February 28, 2010 3:09:19 AM]

Share this post


Link to post
Share on other sites
Thanks guys, I thought I'd already tested it and it ran fine. However, going through my code once more, I realized the function was never called. And guess what: I got (as expected) an access violation writing to 0x000000.

The reason I asked in the first place, was that it seemed to work fine. This was so surprising to me that I wanted to check with the community before starting to use it all over the place. In the end, its not such a big deal. At least I learned something. :)

Share this post


Link to post
Share on other sites

This topic is 2847 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this