"wa"
. If the buffer is allocated or enlarged, this is
achieved using malloc() or realloc(). In this case the returned buffer
should be freed by the caller when done. Example:
{ char buf[1024]; // don't allocate for small stuff char *s = buf; IOSTREAM *fd; size_t size = sizeof(buf); fd = Sopenmem(&s, &size, "w"); ... Sclose(fd); ... if ( s != buf ) // appearently moved Sfree(s); }
The mode is "r"
or "w"
. The mode "rF"
calls
PL_free(buffer)
when closed.
Note: Its is not allowed to access streams created with this call from multiple threads. This is ok for all usage inside Prolog itself. This call is intended to use Sfprintf() and other output functions to create strings.