www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/09/05:37:48

Date: Sun, 9 Nov 1997 12:36:14 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Christopher Croughton <crough45 AT amc DOT de>
cc: djgpp AT delorie DOT com
Subject: Re: Memory allocation
In-Reply-To: <97Nov6.200722gmt+0100.11649@internet01.amc.de>
Message-ID: <Pine.SUN.3.91.971109123555.11475E-100000@is>
MIME-Version: 1.0

On Thu, 6 Nov 1997, Christopher Croughton wrote:

> How standard is the sbrk(2) function?  It's on every Unix I've seen,
> and appears to be in DJGPP as well, but it's not as far as I can tell 
> ANSI.

It's neither ANSI nor POSIX.  (You can tell that by looking at the
DJGPP header that declares it: the prototype is AFTER the
#ifndef _POSIX_SOURCE directive.)

But I have yet to see a C library that doesn't have `sbrk'.  I think
you can pretty much count on it.

> Does it actually work under DJGPP as it does in Unix?

Yes, but note these two gotchas:

     1) It doesn't return memory to the DPMI host when called with a
        negative argument;

     2) It doesn't zero out the memory it gets from the DPMI host
        (unless you use the _CRT0_FLAG_FILL_SBRK_MEMORY flag).

> How about the mmap(2) function?  That sounds really useful if it works...

AFAIK, `mmap' isn't possible with DPMI 0.9, because it doesn't support
page-level protection.  Only DPMI 1.0 can do that.

- Raw text -


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