Path: chuka.playstation.co.uk!news From: sosman@terratron.com (Steven Osman) Newsgroups: scee.yaroze.programming.3d_graphics Subject: Re: Elevation data Date: Thu, 09 Dec 1999 22:32:36 GMT Organization: PlayStation Net Yaroze (SCEE) Lines: 116 Message-ID: <38502d9a.96885804@news.playstation.co.uk> References: <82luhc$6qr1@chuka.playstation.co.uk> <384eda83.10073394@news.playstation.co.uk> <82p7ct$7rp2@chuka.playstation.co.uk> NNTP-Posting-Host: 209.27.57.69 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Newsreader: Forte Agent 1.5/32.452 I'm completely speculating here, but there have been threads fairly recently about different data types needing to be aligned on different byte-boundaries. Is it possible that your linked list "sometimes" gets allocated to the right boundaries, and sometimes doesn't? (Perhaps depending on changes you make in your code?) Again, this is sheer speculation. I remember somebody mentioning that taking care of the alignment is "something you need to do", but no more specifics than that. Steven On Thu, 9 Dec 1999 21:31:37 -0000, "Matthew Hardingham" wrote: >Cheers for that but for some reason it's now working ! >odd that I still don't know what caused it. > >Matt > >Steven Osman wrote in message >news:384eda83.10073394@news.playstation.co.uk... >> You're performing 16384 memory allocations, I wonder if that has >> anything to do with it. Maybe the compiler's memory manager isn't the >> most efficient. >> >> I also wouldn't be surprised if your printf is the problem (did you >> put that in afterwards?) You are printing out 16384 lines also! >> >> An extremely trivial point (incidentally)... This line: >> >> NewVert->Next = NULL; >> >> is redundant >> >> >> Steven >> >> >> On Wed, 8 Dec 1999 15:40:58 -0000, "Matthew Hardingham" >> wrote: >> >> >Right here we go then, >> > >> >At the moment I have a set of elevation points stored in an array >(128x128) >> >from this I'm creating a link list of vertices. >> >For some reason it is running very slow or the program is crashing out. >> >Why ? >> >It's bugging me me now. >> > >> >Here's the vertex structure -- >> > >> > /* Vertex list */ >> > typedef struct Vertex { >> > unsigned short IdxX, IdxZ; >> > VECTOR Vert; /* Vector */ >> > struct Vertex *Next; >> > } VERTEX; >> > >> > >> >Heres a snippet of code where the elevation data is extracted from the >> >array -- >> > >> > /* Loop through the mesh */ >> > for(MeshZ=0; MeshZ> > { >> > for(MeshX=0; MeshX> > { >> > NewVert = AllocateVertex(); >> > >> > NewVert->IdxX = BlockX; >> > NewVert->IdxZ = BlockZ; >> > >> > printf("\n Z - %ld X - %ld", MeshZ, MeshX); >> > >> > /* Set vertices values */ >> > NewVert->Vert.vx = (MeshX*MESH_INTERVAL); >> > NewVert->Vert.vy = HeightArray[MeshZ][MeshX]; >> > NewVert->Vert.vz = (MeshZ*MESH_INTERVAL); >> > >> > /* Change the pointers and link list positions */ >> > CurrentVert->Next = NewVert; >> > NewVert->Next = NULL; >> > CurrentVert = NewVert; >> > } >> > } >> > >> >Here's the allocation part --- >> > >> > /* Vertex memory allocation */ >> > VERTEX *AllocateVertex(void) >> > { >> > VERTEX *V = NULL; >> > >> > V = (VERTEX *)malloc(sizeof(VERTEX)); >> > >> > V->IdxX = 0; V->IdxZ = 0; >> > >> > /* Vertice values */ >> > V->Vert.vx = 0; V->Vert.vy = 0; V->Vert.vz = 0; >> > >> > V->Next = NULL; >> > >> > return(V); >> > } >> > >> > >> > >> > >> > >> >