From 2a71f330b5592502c6e51dff7863698715066780 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Thu, 11 Feb 2021 23:24:25 -0800 Subject: [PATCH 1/2] Allocate fptovp table from heap and release it when done --- src/ldsout.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/ldsout.c b/src/ldsout.c index d91dba7..6cb3295 100644 --- a/src/ldsout.c +++ b/src/ldsout.c @@ -66,9 +66,9 @@ int sysout_loader(const char * sysout_file_name, int sys_size) #ifdef BIGVM /* 1 "cell" per page for 256MB in 512 byte pages */ - unsigned int fptovp[0x80000]; /* FPTOVP */ + unsigned int *fptovp; #else - DLword fptovp[0x10000]; /* FPTOVP */ + DLword *fptovp; /* FPTOVP */ #endif /* BIGVM */ long fptovp_offset; /* FPTOVP start offset */ @@ -221,7 +221,7 @@ int sysout_loader(const char * sysout_file_name, int sys_size) if ((stat_buf.st_size & (BYTESPER_PAGE - 1)) != 0) printf("CAUTION::not an integral number of pages. sysout & 0x1ff = 0x%x\n", - (int)(stat_buf.st_size & (BYTESPER_PAGE - 1))); + (int)(stat_buf.st_size & (BYTESPER_PAGE - 1))); if (ifpage.nactivepages != (sysout_size / 2)) { printf("sysout_loader:IFPAGE says sysout size is %d\n", ifpage.nactivepages); @@ -248,19 +248,23 @@ int sysout_loader(const char * sysout_file_name, int sys_size) #ifdef BIGVM /* fptovp is now in cells, not words */ + fptovp = malloc(sysout_size * 2 + 4); if (read(sysout, fptovp, sysout_size * 2) == -1) { perror("sysout_loader: can't read FPTOVP"); + free(fptovp); exit(-1); } #ifdef BYTESWAP word_swap_page((unsigned short *)fptovp, (sysout_size / 2) + 1); /* So space to swap is twice as big, too. */ -#endif /* BYTESWAP */ +#endif /* BYTESWAP */ #else + fptovp = malloc(sysout_size + 2); if (read(sysout, fptovp, sysout_size) == -1) { perror("sysout_loader: can't read FPTOVP"); + free(fptovp); exit(-1); } @@ -303,6 +307,7 @@ int sysout_loader(const char * sysout_file_name, int sys_size) if (GETPAGEOK(fptovp, i) != 0177777) { if (lseek(sysout, i * BYTESPER_PAGE, SEEK_SET) == -1) { perror("sysout_loader: can't seek sysout file"); + free(fptovp); exit(-1); }; lispworld_offset = GETFPTOVP(fptovp, i) * BYTESPER_PAGE; @@ -315,6 +320,7 @@ int sysout_loader(const char * sysout_file_name, int sys_size) int j; for (j = 0; j < 10; j++) printf(" %d: 0x%x ", j, GETFPTOVP(fptovp, j)); } + free(fptovp); exit(-1); }; #ifdef BYTESWAP @@ -322,7 +328,7 @@ int sysout_loader(const char * sysout_file_name, int sys_size) #endif }; } - + free(fptovp); DBPRINT(("sysout file is read completely.\n")); #if (defined(DISPLAYBUFFER) || defined(XWINDOW) || defined(DOS)) From 0d7dcc24bdf902bf2eb1a3faa22e86964a9c8ea0 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Thu, 11 Feb 2021 23:35:38 -0800 Subject: [PATCH 2/2] Minor formatting revisions. --- src/ldsout.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/ldsout.c b/src/ldsout.c index 6cb3295..58eac7d 100644 --- a/src/ldsout.c +++ b/src/ldsout.c @@ -2,11 +2,11 @@ */ /************************************************************************/ -/* */ -/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1998 Venue. */ -/* All Rights Reserved. */ -/* Manufactured in the United States of America. */ -/* */ +/* */ +/* (C) Copyright 1989, 1990, 1990, 1991, 1992, 1993, 1994, 1998 Venue. */ +/* All Rights Reserved. */ +/* Manufactured in the United States of America. */ +/* */ /************************************************************************/ #include "version.h" @@ -40,16 +40,15 @@ #define MAX_EXPLICIT_SYSOUTSIZE 256 /* Max possible sysout size is 64Mb */ #define MBYTE 0x100000 /* 1 Mbyte */ -/* Flag for indication whether process space - is going to expand or not */ +/* Flag for indication whether process space is going to expand or not */ int Storage_expanded; /* T or NIL */ /************************************************************************/ -/* */ -/* s y s o u t _ l o a d e r */ -/* */ -/* Load the sysout file into memory. */ -/* */ +/* */ +/* s y s o u t _ l o a d e r */ +/* */ +/* Load the sysout file into memory. */ +/* */ /************************************************************************/ #if defined(DOS) || defined(XWINDOW) #include "devif.h" @@ -58,8 +57,7 @@ extern DspInterface currentdsp; #endif /* DOS || XWINDOW */ /* sys_size is sysout size in megabytes */ -int sysout_loader(const char * sysout_file_name, int sys_size) -{ +int sysout_loader(const char *sysout_file_name, int sys_size) { int sysout; /* SysoutFile descriptor */ IFPAGE ifpage; /* IFPAGE */ @@ -138,8 +136,9 @@ int sysout_loader(const char * sysout_file_name, int sys_size) exit(-1); } #endif /* NOVERSION */ - if (sys_size == 0) /* use default or the previous one */ - { + + /* use default or the previous one */ + if (sys_size == 0) { if (ifpage.process_size == 0) /* Pure LISP.SYSOUT */ sys_size = DEFAULT_MAX_SYSOUTSIZE; /* default for pure SYSOUT */ else @@ -221,7 +220,7 @@ int sysout_loader(const char * sysout_file_name, int sys_size) if ((stat_buf.st_size & (BYTESPER_PAGE - 1)) != 0) printf("CAUTION::not an integral number of pages. sysout & 0x1ff = 0x%x\n", - (int)(stat_buf.st_size & (BYTESPER_PAGE - 1))); + (int)(stat_buf.st_size & (BYTESPER_PAGE - 1))); if (ifpage.nactivepages != (sysout_size / 2)) { printf("sysout_loader:IFPAGE says sysout size is %d\n", ifpage.nactivepages); @@ -244,7 +243,7 @@ int sysout_loader(const char * sysout_file_name, int sys_size) exit(-1); } -/* read FPTOVP */ + /* read FPTOVP */ #ifdef BIGVM /* fptovp is now in cells, not words */ @@ -256,7 +255,8 @@ int sysout_loader(const char * sysout_file_name, int sys_size) } #ifdef BYTESWAP - word_swap_page((unsigned short *)fptovp, (sysout_size / 2) + 1); /* So space to swap is twice as big, too. */ + /* So space to swap is twice as big, too. */ + word_swap_page((unsigned short *)fptovp, (sysout_size / 2) + 1); #endif /* BYTESWAP */ #else