sector1.triangle = new TRIANGLE[numtriangles];
Malloc Question
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
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
Ya I tried that but I got this error.
any ideas
Thanks vbuser
*** malloc: vm_allocate(size=3021615104) failed (error code=3)*** malloc[1376]: error: Can't allocate region
any ideas
Thanks vbuser
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.
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
-me
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?
Either sizeof(TRIANGLE) is insanely large, or numtriangles is insanely large.
What is sizeof(TRIANGLE) and numtriangles supposed to be?
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
vbuser
Quote:Original post by vbuser1338
but You can't use new in Cocoa on mac.
Mmmmmm, Objective-C...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement