This commit is contained in:
Vitor Santos Costa 2018-07-14 11:49:42 +01:00
parent 069fcc875c
commit 86c71b6da7

View File

@ -259,11 +259,14 @@ open_mem_write_stream(USES_REGS1) /* $open_mem_write_stream(-Stream) */
* by other writes.. * by other writes..
*/ */
char *Yap_MemExportStreamPtr(int sno) { char *Yap_MemExportStreamPtr(int sno) {
FILE *f = GLOBAL_Stream[sno].file;
if (fflush(GLOBAL_Stream[sno].file) < 0) { if (fflush(f) < 0) {
return NULL; return NULL;
} }
size_t len = fseek(GLOBAL_Stream[sno].file, 0, SEEK_END); if (fseek(f, 0, SEEK_END) < 0) {
return NULL;
}
size_t len = ftell(f);
char *buf = malloc(len+1); char *buf = malloc(len+1);
#if HAVE_OPEN_MEMSTREAM #if HAVE_OPEN_MEMSTREAM
char *s = GLOBAL_Stream[sno].nbuf; char *s = GLOBAL_Stream[sno].nbuf;