Sign in to follow this  
vbuser1338

Malloc Question

Recommended Posts

I read the post below and I didn't see an answer that worked. I want to declare a Sector for a OpenGl project. And it has to have an array of Triangles in it which is another structure. But I want to make the array of triangles the size that I load from the file. So I was going to use
sector1.triangle = new TRIANGLE[numtriangles];
but You can't use new in Cocoa on mac. triangle in the Sector is a Pointer to the structure Triangles. So how would I make say I load the number 36 make sector1.triangle[36] using maloc? Thanks vbuser

Share this post


Link to post
Share on other sites
Quote:
Original post by vbuser1338
*** malloc: vm_allocate(size=3021615104) failed (error code=3)

3021615104 is the size you're trying to allocate in bytes, it seems. I don't think so, that's a hell of a lot of RAM. Your numtriangles value is wrong.

Share this post


Link to post
Share on other sites
It looks like you are asking it to malloc 3GB of memory. Do you have that much memory on your computer? if not, then you have too many TRIANGLES, or as mentioned above, numTriangles is wrong.

-me

Share this post


Link to post
Share on other sites
Ya I'm stupid when I went to load the num triangles I was going to a point in the file that didn't exist . I was trying to get the number after numPolygons and In my file it is numTriangles so It was putting a weird number into numtriangles. Another stupid mistake. But thanks for the help.
vbuser

Share this post


Link to post
Share on other sites

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