On Solaris this function is not yet available.
getentropy \
getexecname \
getline \
+ open_memstream \
pstat_getproc \
sysconf \
])
#include <string.h>
static int
-test_memstream(FILE *fp, size_t bufsz)
+test_memstream(void)
{
+ int rc = 0;
+#if HAVE_OPEN_MEMSTREAM
+ FILE *fp;
+ char *buf = NULL;
+ size_t bufsz = 0;
+
+ fp = open_memstream(&buf, &bufsz);
+ if (fp == NULL)
+ return 1;
+
fputs("World", fp);
if (fpurge(fp) < 0)
- return 1;
+ rc = 1;
fflush(fp);
if (bufsz != 0)
- return 1;
- return 0;
+ rc = 1;
+
+ fclose(fp);
+ free(buf);
+#endif
+
+ return rc;
}
int
main(int argc, char *argv[])
{
FILE *fp;
- char *buf = NULL;
- size_t bufsz = 0;
int rc;
if (fpurge(NULL) == 0)
fp = fopen("/dev/zero", "r");
if (fpurge(fp) < 0)
return 1;
-
fclose(fp);
- fp = open_memstream(&buf, &bufsz);
- rc = test_memstream(fp, bufsz);
- fclose(fp);
- free(buf);
+ rc = test_memstream();
return rc;
}