BSD 4_3 release
[unix-history] / usr / src / lib / libc / stdio / setbuffer.c
index 290d113..7b3c1fc 100644 (file)
@@ -1,8 +1,17 @@
-/* @(#)setbuffer.c     4.3 (Berkeley) %G% */
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)setbuffer.c        5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
 #include       <stdio.h>
 
 setbuffer(iop, buf, size)
 #include       <stdio.h>
 
 setbuffer(iop, buf, size)
-       register struct _iobuf *iop;
+       register FILE *iop;
        char *buf;
        int size;
 {
        char *buf;
        int size;
 {
@@ -23,11 +32,16 @@ setbuffer(iop, buf, size)
  * set line buffering for either stdout or stderr
  */
 setlinebuf(iop)
  * set line buffering for either stdout or stderr
  */
 setlinebuf(iop)
-       register struct _iobuf *iop;
+       register FILE *iop;
 {
 {
+       char *buf;
        extern char *malloc();
 
        fflush(iop);
        extern char *malloc();
 
        fflush(iop);
-       setbuffer(iop, malloc(BUFSIZ), BUFSIZ);
-       iop->_flag |= _IOLBF|_IOMYBUF;
+       setbuffer(iop, NULL, 0);
+       buf = malloc(BUFSIZ);
+       if (buf != NULL) {
+               setbuffer(iop, buf, BUFSIZ);
+               iop->_flag |= _IOLBF|_IOMYBUF;
+       }
 }
 }