Jump to content
  • Advertisement
Sign in to follow this  
vbuser1338

Malloc Question

This topic is 4871 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 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
Advertisement
Ya I tried that but I got this error.

*** malloc: vm_allocate(size=3021615104) failed (error code=3)
*** malloc[1376]: error: Can't allocate region


any ideas
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
It seems to be trying to allocate 3gig of data, and, well, thats rather huge.

Either sizeof(TRIANGLE) is insanely large, or numtriangles is insanely large.

What is sizeof(TRIANGLE) and numtriangles supposed to be?

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
Quote:
Original post by vbuser1338
but You can't use new in Cocoa on mac.


Mmmmmm, Objective-C...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!