(char *)(-1)
david Fridley
david at psitech.UUCP
Mon Jul 31 16:38:36 AEST 1989
In article <18792 at mimsy.UUCP>, chris at mimsy.UUCP (Chris Torek) writes:
> >>... if NULL is returned there was an error getting the next string,
> >>if (-1) is returned there were no more symbols.
>
> >Is it safe to return -1?
>
To quote from the my UNIX System V (Release 3.0) Programmers Reference manual
for BRK(2) (page 141):
NAME
brk,sbrk - change data segment allocation
SYNOPSIS
int brk (endds)
char *endds;
char *sbrk (incr)
int incr;
:
:
DIAGNOSTICS
Upon successful completion, brk returns a value 0 and sbrk returns the old
break value. Otherwise, a value of -1 is returned and errno is set to
indicate the error.
Here we see that sbrk(), a standard UNIX function, which returns a character
pointer will return (-1). This is the functioin used by malloc() to get
free more free memory from the operation system.
--
david.
DISCLAIMER: If it's important have a backup. If it ain't broke don't fix it.
Proceed at your own risk. My oponions are MY own. Spelling does not count.
My fondest dream is to leave this planet.
More information about the Comp.std.c
mailing list