Subject: Re: PROPOSAL: removal of brk()/sbrk().
To: None <tech-kern@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: tech-kern
Date: 02/28/2002 19:02:21
In article <3C7E6E7C.2070005@mac.com>, Andrew Cagney <cagney@mac.com> wrote:
>Probably stupid but related question.
>
>Does sbrk() return zero'ed memory.  Looking at some code (moncontrol()) 
>it appears to assume this.
>
>Andrew
>

Maybe if it comes fresh from uvm :-)... Otherwise no guarantees.

christos

#include <stdio.h>
#include <unistd.h>


int
main(int argc, char *argv[]) {
#define SIZE	4096
	void *old = sbrk(0);
	sbrk(SIZE);
	memset(old, -1, SIZE);
	brk(old);
	sbrk(SIZE);
	if ((*(char *)old) == '\0')
		printf("zero\n");
	else
		printf("one\n");

	return 0;
}