Path: chuka.playstation.co.uk!news From: Chris Chadwick Newsgroups: scee.yaroze.programming.gnu_compiler Subject: Re: Memory allocation probs... Date: Fri, 31 Oct 1997 00:47:26 -0800 Organization: PlayStation Net Yaroze (SCEE) Lines: 37 Message-ID: <34599B1E.4515@dial.pipex.com> References: <34551BB5.58BA@dial.pipex.com> <3454c596.21265918@news.playstation.co.uk> <3456076E.92B9FC58@micronetics.com> <3456FA5F.DB8@dial.pipex.com> <345695E0.6102@peace.co.nz> <3457216F.61478ECA@micronetics.com> NNTP-Posting-Host: ai205.du.pipex.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 2.02 (Win95; I; 16bit) Me again (sorry!), Let me see if I've got this straight. Before I can malloc/calloc memory I need to call InitHeap(). OK. InitHeap() takes 2 args: void *head long size First, whats the best way to find an appropriate value for 'head', which is a pointer to where you want the start of heap mem to be?... According to the yellow manual, the GP register points to the middle of the BSS session which can be *upto* 64K in size. BSS is placed directly after the program segments; this seems to be verified to me because GP is displayed as pointing approx 32K beyond my program segs, when I download from SIOCONS. So, I assume the best value for 'head' would be directly after BSS. But, of course, while a prog is in development it's going to get bigger, so its better to set 'head' some way beyond BSS (to allow for growth) until the prog is finished, right? Now, arg 'size' is the amount of mem you want to allocate as the heap, specified in 4-byte units ('head' has to be a 4-byte aligned address as well, then?). Do I, then, have to make sure I don't allocate so much mem that the stack may creep down and clash with it? Also, Im currently using the small piece of inline asm code that puts the stack in the 1K DCache, so I can ignore this consideration anyway, yeah? And the last thing, the manual says that all of 'size' mem will not be available for allocation because of an 'overhead'. How much will this overhead be? Well, that's how far I've got to understanding all this. I hope someone can help make it clear, once and for all, for me :) Blinkey-blimey! Im beginning to wish I'd stuck to using static arrays. Thanks, Chris