X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-workers-bounces using -f Message-ID: <3C79833E.7282AF8D@yahoo.com> Date: Sun, 24 Feb 2002 19:20:14 -0500 From: CBFalconer Organization: Ched Research X-Mailer: Mozilla 4.75 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: djgpp-workers AT delorie DOT com Subject: Re: Malloc/free DJGPP code References: <10202201713 DOT AA23034 AT clio DOT rice DOT edu> <3C7919F2 DOT 96FFA97D AT yahoo DOT com> <200202241740 DOT g1OHeOd19302 AT envy DOT delorie DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com DJ Delorie wrote: > > > This could all be cured by a semi-portable implementation of, say, > > "fakesbrk" which will return a repeatable set of addresses under > > the same circumstances. It might actually malloc a large block > > which contains those addresses to be faked. But how can it ensure > > that a certain range is available to any degree of certainty, or > > even of probability? > > Put a huge uninitialized static array in your program and use it for > sbrk. It will always be in the same virtual address. Do you see any problem with the following? I was surprised to read that sbrk returns -1 for failure. This way the test program can fool with it by making small silly allocations to foul the sequence. I'll worry about going backwards later. #include "fakesbrk.h" enum {FAKESIZE = 1234567}; char fakearea[FAKESIZE]; /* 1------------------1 */ /* we can fool with this to generate test cases */ void *fakesbrk(int delta) { static char *unused = fakearea; char *next, *p; next = unused + delta; if ((unsigned) next > FAKESIZE) return (void *)-1; else { p = unused; unused = next; return (void *)p; } } /* fakesbrk */ -- Chuck F (cbfalconer AT yahoo DOT com) (cbfalconer AT XXXXworldnet DOT att DOT net) Available for consulting/temporary embedded and systems. (Remove "XXXX" from reply address. yahoo works unmodified) mailto:uce AT ftc DOT gov (for spambots to harvest)