delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/07/10:34:52

From: Christopher Croughton <crough45 AT amc DOT de>
Message-Id: <97Nov7.172634gmt+0100.11651@internet01.amc.de>
Subject: Re: Memory allocation
To: eldredge AT ap DOT net (Nate Eldredge)
Date: Fri, 7 Nov 1997 16:32:06 +0100
Cc: crough45 AT amc DOT de, djgpp AT delorie DOT com
In-Reply-To: <199711062353.PAA29975@adit.ap.net> from "Nate Eldredge" at Nov 7, 97 00:53:38 am
Mime-Version: 1.0

Nate Eldredge wrote:
> 
> IIRC, sbrk() is POSIX and has been in Unix forever. 

It doesn't say POSIX in the man page here (Dec Alpha, OSF/1), but that 
doesn't necessarily mean anything...

> You should be able to find it in every Unix, and many DOS compilers also.
> DJGPP obviously has it, and I think Turbo C has some cheap imitation as
> well. Using it directly is quite likely to screw up malloc(), which usually
> depends on being the only thing manipulating the break-point.  Also, I'm not
> sure why you'd need to use it directly; malloc() can give most of the same
> functionality and is almost totally portable.

A version of malloc/free which uses sbrk to get/release memory.  I was 
wondering if I could use it in parallel with the existing malloc/free
and suspecting not.

> AFAIK, yes. It gives your program N more bytes of memory, and returns a
> pointer to it.

And frees it?  ISTR a comment here about it not actually freeing the memory
again.

> I think mmap() is only available on fairly recent Unix implementations.
> DJGPP definitely doesn't have it, and I'd be surprised if any other DOS
> compiler package did.

Oh well.  It would be very useful if it did, but if it's not portable ten
I'll just have to do without...

Thanks,
    Chris C

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019