Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/lib/libc/gen/getcwd.c,v retrieving revision 1.3.4.1 retrieving revision 1.4 diff -u -p -r1.3.4.1 -r1.4 --- src/lib/libc/gen/getcwd.c 1995/05/02 19:34:46 1.3.4.1 +++ src/lib/libc/gen/getcwd.c 1995/02/27 04:12:20 1.4 @@ -1,6 +1,8 @@ +/* $NetBSD: getcwd.c,v 1.4 1995/02/27 04:12:20 cgd Exp $ */ + /* - * Copyright (c) 1989, 1991 The Regents of the University of California. - * All rights reserved. + * Copyright (c) 1989, 1991, 1993 + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -32,13 +34,16 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)getcwd.c 5.11 (Berkeley) 2/24/91";*/ -static char *rcsid = "$Id: getcwd.c,v 1.3.4.1 1995/05/02 19:34:46 jtc Exp $"; +#if 0 +static char sccsid[] = "@(#)getcwd.c 8.1 (Berkeley) 6/4/93"; +#else +static char rcsid[] = "$NetBSD: getcwd.c,v 1.4 1995/02/27 04:12:20 cgd Exp $"; +#endif #endif /* LIBC_SCCS and not lint */ -#include "namespace.h" #include #include + #include #include #include @@ -77,12 +82,12 @@ getcwd(pt, size) ptsize = 0; if (!size) { errno = EINVAL; - return((char *)NULL); + return (NULL); } ept = pt + size; } else { - if (!(pt = (char *)malloc(ptsize = 1024 - 4))) - return((char *)NULL); + if ((pt = malloc(ptsize = 1024 - 4)) == NULL) + return (NULL); ept = pt + ptsize; } bpt = ept - 1; @@ -93,7 +98,7 @@ getcwd(pt, size) * Should always be enough (it's 340 levels). If it's not, allocate * as necessary. Special * case the first stat, it's ".", not "..". */ - if (!(up = (char *)malloc(upsize = 1024 - 4))) + if ((up = malloc(upsize = 1024 - 4)) == NULL) goto err; eup = up + MAXPATHLEN; bup = up; @@ -127,7 +132,7 @@ getcwd(pt, size) */ (void)bcopy(bpt, pt, ept - bpt); free(up); - return(pt); + return (pt); } /* @@ -136,8 +141,9 @@ getcwd(pt, size) * possible component name, plus a trailing NULL. */ if (bup + 3 + MAXNAMLEN + 1 >= eup) { - if (!(up = (char *)realloc(up, upsize *= 2))) + if ((up = realloc(up, upsize *= 2)) == NULL) goto err; + bup = up; eup = up + upsize; } *bup++ = '.'; @@ -196,7 +202,7 @@ getcwd(pt, size) } off = bpt - pt; len = ept - bpt; - if (!(pt = (char *)realloc(pt, ptsize *= 2))) + if ((pt = realloc(pt, ptsize *= 2)) == NULL) goto err; bpt = pt + off; ept = pt + ptsize; @@ -226,5 +232,5 @@ err: if (ptsize) free(pt); free(up); - return((char *)NULL); + return (NULL); }