*BSD News Article 36538


Return to BSD News archive

Xref: sserve comp.os.misc:3344 comp.unix.bsd:15027 comp.unix.internals:7782 comp.unix.programmer:20576
Newsgroups: comp.os.misc,comp.unix.bsd,comp.unix.internals,comp.unix.programmer,comp.unix.quest1ions
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!msuinfo!agate!howland.reston.ans.net!EU.net!uknet!festival!edcogsci!richard
From: richard@cogsci.ed.ac.uk (Richard Tobin)
Subject: Re: Question: What exactly does sbrk(0) do?
Message-ID: <Cx5oJM.1It@cogsci.ed.ac.uk>
Keywords: Question: What exactly does sbrk(0) do?
Organization: HCRC, University of Edinburgh
References: <36n65p$blf@sal-sun2.usc.edu>
Date: Tue, 4 Oct 1994 16:02:09 GMT
Lines: 19

In article <36n65p$blf@sal-sun2.usc.edu> fabbroci@sal-sun2.usc.edu (Frank Fabbrocino) writes:
> does anyone know where I can get more info
>on that specific call of sbrk() with 0 as an arg?

Someone else has given more details, but just to be explicit about
this point: there is nothing special about the zero argument.  sbrk(n)
increases the program size by n bytes and returns a pointer to those n
bytes, which start where the data segment previously ended.  sbrk(0)
just increases the size by zero bytes (ie leaves it unchanged) and
returns a pointer to where the data segment previously ended, which is
of course where it still ends, since you didn't allocate any bytes.

-- Richard

-- 
Richard Tobin, HCRC, Edinburgh University                 R.Tobin@ed.ac.uk

Ooooh!  I didn't know we had a king.  I thought we were an
autonomous collective.