From: "Toni Riikonen" Newsgroups: comp.os.msdos.djgpp Subject: Vs: DJGPP malloc problem Date: Fri, 3 Mar 2000 17:42:05 +0200 Organization: Tampere Telephone Plc Lines: 69 Message-ID: <89omg0$l5a$1@news.koti.tpo.fi> References: <89n24n$5rq$1 AT news DOT koti DOT tpo DOT fi> <38BF7F73 DOT CAEBED9A AT is DOT elta DOT co DOT il> NNTP-Posting-Host: line79.dyn.tutka.net X-Trace: news.koti.tpo.fi 952098112 21674 212.116.32.79 (3 Mar 2000 15:41:52 GMT) X-Complaints-To: abuse AT tpo DOT fi NNTP-Posting-Date: 3 Mar 2000 15:41:52 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Eli Zaretskii kirjoitti viestissä:38BF7F73 DOT CAEBED9A AT is DOT elta DOT co DOT il... > Toni Riikonen wrote: > > > > BUT, when i'm trying to, for example, print something out of these > > structures, my computer crashes, or boots up! > > > > This is what i'm trying to do.. > > > > ---------------------------------------------- > > int main() > > { > > int a; > > object_type object; > > InitObject(&object, 50); > > for(a = 0;a < object.faces; a++) { > > gotoxy(1,1+a); > > printf("%1.1f\n",object.face[a].vertex[0].rx); > > } > > free(object.face); > > return 0; > > } > > -------------------------------------------------- > > There's no declaration or initialization of the vertex[] array in the above > code. Is this the real program you compiled and tried to run? Yeah, but face-structure has vertex_types in it.., so... And Yes, this is the program that i compiled and run, but of course i have the typedef-things in the start (new_def.h), and the init-code: void InitObject(object_type *obj, int faces) { obj->face = (face_type *)malloc( sizeof(face_type) * faces); if(obj->face == NULL) exit(1); object.faces = faces; } It's so weird, this program WORKS, if it is just like that!! I have these matrix-structures in my object and when i'm trying to use the matrixes with those vertex-coordinates my compiler-(debug, breakpoint) says that something like "Floating point exeption", or something similar.. my object -structure: typedef float matrix_type[3][3]; typedef struct object_type { signed int x,y,z; float rx,ry,rz; float ax,ay,az; face_type *face; unsigned int faces; matrix_type object_matrix, world_matrix; } object_type; So, when i'm trying to use for example object.world_matrix, rhides debug cancel program on call to printf("%1.1f",object.object_matrix[0][0]); And claims there is a floating point exeption?? I'm have no idea what this means! What is going on??