+ flags &= ~(__SLBF | __SNBF | __SMBF);
+
+ if (size == 0)
+ buf = NULL; /* we will make a real one later */
+ else if (buf == NULL) {
+ /*
+ * Caller wants specific buffering mode and size but did
+ * not provide a buffer. Produce one of the given size.
+ * If that fails, set the size to 0 and continue, so that
+ * we will try again later with a system-supplied size
+ * (failure here is probably from someone with the bogus
+ * idea that larger is always better, asking for many MB),
+ * but return EOF to indicate failure.
+ */
+ if ((buf = malloc(size)) == NULL) {
+ ret = EOF;
+ size = 0;
+ } else
+ flags |= __SMBF;
+ }