[comp.sys.next] Is there a replacement for sbrk

bwbe_c52@uhura.cc.rochester.edu (Brent Benson) (03/02/90)

I'm trying to port an application to the NeXT that uses the
sbrk() UNIX system call.  I got a memory allocation error when
trying to run the program, and the man page says:

	The UNIX system calls `brk' and `sbrk' are not supported
	on the NeXT computer.

Does anyone have a clue as to what I should do?

Thanks in advance,
-Brent

-- 
 _                    _     
| |_  ___  ___  __  _| |_  Brent Benson - University of Rochester
|  .\|  _\/ ._\|  \|_   _| e-mail: bwbe_ltd@uhura.cc.rochester.edu
|___/|_|  \___/|_|_| |_|       ..!rochester!ur-cc!bwbe_ltd

hue@netcom.UUCP (Jonathan Hue) (03/04/90)

In article <5532@ur-cc.UUCP> bwbe_c52@uhura.cc.rochester.edu (Brent Benson) writes:
>
>I'm trying to port an application to the NeXT that uses the
>sbrk() UNIX system call.  I got a memory allocation error when
>trying to run the program, and the man page says:
>
>	The UNIX system calls `brk' and `sbrk' are not supported
>	on the NeXT computer.
>
>Does anyone have a clue as to what I should do?

I was under the impression that even though these syscalls aren't supported,
they actually still worked.  I've been running rayshade (recently posted
to comp.sources.unix) and using the malloc provided in the rayshade sources,
and it must call brk() or sbrk().  I wasn't able to use the NeXT malloc
because rayshade depends on being able to access a chunk of memory
after it's been free()'d.  This is just a guess, but it looks like the
NeXT malloc() will vm_deallocate() a page of memory if everything on it has
been free()'d, so rayshade kept getting segmentation violations.

I just added lines to the Makefile like -Dmalloc=ray_malloc -Dfree=ray_free
and the whole thing compiled and I now have a lot of really nice pictures.
If anyone wants a program which will take rayshade MTV output and FS-dither
it down to a 2-bit EPS file, send me e-mail.

-Jonathan