Path: chuka.playstation.co.uk!news From: "Steve Dunn" Newsgroups: scea.yaroze.programming.codewarrior,scee.yaroze.programming.codewarrior Subject: Libraries again...(and malloc) Date: Sun, 8 Mar 1998 18:17:26 -0000 Organization: PlayStation Net Yaroze (SCEE) Lines: 55 Message-ID: <6dunc7$iap22@chuka.playstation.co.uk> NNTP-Posting-Host: userl855.uk.uudial.com X-Newsreader: Microsoft Outlook Express 4.72.2106.4 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4 Xref: chuka.playstation.co.uk scea.yaroze.programming.codewarrior:290 scee.yaroze.programming.codewarrior:193 Hi there, I've got the libraries semi working. Thanks to all that replied. I have a library called 3DLib.lib. A class in this library allocates memory for order tables and packet buffers. The problem is that malloc is allocating all over the code area. It goes like this... Main PSX exe is located at 0x80140000 and is 0x4000 (16384) bytes in length. Assuming the heap is initialised correctly (anyone know how to step into this in psstart.c?) the next available memory address should be > 0x80144000 right? Well.... To test the problem, I have simply stuck in the following in a method in one of the classes exported from the library. void* p = NULL ; p = malloc( 100 ) ; Looking at 'p', it turns out that 'malloc' has decided that 0x801432B4 is the best place to put the memory. As soon as the alloc is called the 'this' pointer goes bezerk, changing from 0x801FFEEC to 0xFFFFFFFE, and depending on what's being done next, some very exotic errors appear, from the run of the mill 'bus error' right up to errors that get very personal and threatening. My questions are(in order of importance and annoyance)... Why is malloc misbehaving ? What is the relevance of the 'code address' for libraries ? How do you step into the 'init heap' code supplied via the 'stationary' ? Why can't the 'code model' be changed to 'position independent code' for libs? Am I being completely thick and missing something that a blind donkey could spot whilst juggling and whistling with a mouth-full of carrots ?